Skip to content

Instantly share code, notes, and snippets.

@yao2030
Created April 12, 2013 01:58
Show Gist options
  • Save yao2030/5368707 to your computer and use it in GitHub Desktop.
Save yao2030/5368707 to your computer and use it in GitHub Desktop.
SICP Exercise 4.7
(define (let*->nested-lets clauses)
(if (null? (car clauses))
(cadr clauses)
(list 'let (list (caar clauses))
(let*->nested-lets (cons (cdar clauses)
(cdr clauses))))))
1 ]=> (let*->nested-lets '(((x 3) (y (+ x 2)) (z (+ x y 5))) (* x z)))
;Value 18: (let ((x 3)) (let ((y (+ x 2))) (let ((z (+ x y 5))) (* x z))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment