Expressions are either primitive or compound. Procedures are either primitive or compound. A combination is an expression of the form (operator operands ...). This is my Clojure solution to Chapter 1, Exercise 4:
(ns sicp.ch1.ex04)
(defn a-plus-abs-b
[a b]
((if (pos? b) + -) a b))
(a-plus-abs-b 5 -10) ; => 15
(a-plus-abs-b 5 10) ; => 15
(ns sicp.ch1.ex04)
(defn a-plus-abs-b
[a b]
((if (pos? b) + -) a b))
(a-plus-abs-b 5 -10) ; => 15
(a-plus-abs-b 5 10) ; => 15
No comments:
Post a Comment