Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fun with lets and lambdas
#1
Code:
(define (f z)
    (let ((a (- z 1))
          (b (+ z 1))
          )
        (+ (* a a) (* b b))
        )
    )

(define (g z)
    (define a (- z 1))
    (define b (+ z 1))
    (+ (* a a) (* b b))
    )

(define (h z)
    ((lambda (a b)
        (+ (* a a) (* b b))
        ) (- z 1) (+ z 1))
    )

(define (i z)
    (((lambda (b)
        (lambda (a)
            (+ (* a a) (* b b))
            )
        ) (+ z 1))
            (- z 1))
    )

(inspect (f 5))
(inspect (g 5))
(inspect (h 5))
(inspect (i 5))
# all should compute 52
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)