Skip to content

Instantly share code, notes, and snippets.

@jimweirich
Forked from redsquirrel/gist:189193
Created September 18, 2009 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimweirich/189244 to your computer and use it in GitHub Desktop.
Save jimweirich/189244 to your computer and use it in GitHub Desktop.
;; SICP 1.4
;;
;; Exercise 1.4. Observe that our model of evaluation allows for
;; combinations whose operators are compound expressions. Use this
;; observation to describe the behavior of the following procedure:
(define (a-plus-abs-b a b)
((if (> b 0) + -) a b))
;; (a-plus-abs-b 2 3)
;; ((if (> 3 0) + -) 2 3) ;; First expansion
;; ((if true + -) 2 3) ;; Expand condition
;; (+ 2 3) ;; Substitute if
;; 5 ;; Substitute the addition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment