views:

287

answers:

1

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.

+5  A: 

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

(define (f g) 
  (let ((x 1) (y (* g 2))) 
       (+ x y)))
Logan Capaldo
Thanks, but sadly in the "beginning language" subset of drscheme there is no `let`. Still, obviously the correct answer.
If you know Haskell, you are probably better off with not using the "beginning language" subset of Drscheme. The entirety of scheme is already small, much smaller than Haskell.
Nathan Sanders