Skip to content

Instantly share code, notes, and snippets.

@bmabey
Forked from redsquirrel/gist:189193
Created September 19, 2009 21:43
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 bmabey/189601 to your computer and use it in GitHub Desktop.
Save bmabey/189601 to your computer and use it in GitHub Desktop.
SICP Exercise 1.4
;; 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))
; The behaviour of interest in this code sample is when the if procedure
; is evaluated it returns an operator which is then applied to the
; remaining elemetns of the list. This is interesting to me because of the
; implicit application of the operator (- or +). Since the if procedure is
; evalutaed and expanded out first it reduces to:
; (+ a b) ; | b > 0
; (- a b) ; | b <= 0
@osmya
Copy link

osmya commented Nov 27, 2018

Is this the solution / explanation? So the code is valid?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment