vivav
vivav

Reputation: 135

Scheme: return 10 if a function returns true

I'm trying to implement a part where if my separate function 'write?' (which returns true or false) returns true, I want it to return the number 10.

(define value 
  (lambda (p gs) 
    (cond 
     ((write? p gs) #t)
     10 
     else 0)))

I know this is not correct because I'm getting errors, but this is the skeleton of it. I wanted it to do if write? with those parameters returns true, then have value return 10. If not, return 0.

Thank you.

Upvotes: 0

Views: 886

Answers (1)

C. K. Young
C. K. Young

Reputation: 223023

(cond
  ((write? p gs) 10)
  (else 0))

Upvotes: 1

Related Questions