Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scheme equivalent to Haskell where clause

I am just learning scheme, but I would love to be able to repeat myself less.

Is there a way I can assign a name to a subexpression in the local scope?

As per the comment:

Haskell where clause

x = s * t 
  where s = 10
        t = 20

x should be 200 in this case.

like image 282
solinent Avatar asked Jan 23 '23 04:01

solinent


1 Answers

Let (or letrec for recursive bindings), e.g.:

(define (f g) 
  (let ((x 1) (y (* g 2))) 
       (+ x y)))
like image 152
Logan Capaldo Avatar answered Jan 26 '23 11:01

Logan Capaldo