From: Ramakrishnan Muthukrishnan Date: Thu, 27 May 2010 14:26:12 +0000 (+0530) Subject: solution to 1.41 X-Git-Url: https://git.rkrishnan.org/pf/content/en/service/@manifest?a=commitdiff_plain;h=9823a764a5c40811621967fda7beaba9c162bb86;p=sicp.git solution to 1.41 --- diff --git a/src/sicp/ex1_41.clj b/src/sicp/ex1_41.clj new file mode 100644 index 0000000..17bf21c --- /dev/null +++ b/src/sicp/ex1_41.clj @@ -0,0 +1,22 @@ +(ns sicp.ex1_41 + (:use [clojure.contrib test-is] + [sicp utils] + [sicp ch1_3])) + +(defn doub [f] + (fn [x] (f (f x)))) + +(comment +(((doub (doub doub)) inc) 5) +;;=> 21 +user> ((doub inc) 1) +;;=> 3 +user> (((doub doub) inc) 1) +;;=> 5 +user> (((doub (doub doub)) inc) 1) +;;=> 17 +user> (((doub (doub (doub doub))) inc) 1) +;;=> 257 +user> (((doub (doub (doub (doub doub)))) inc) 1) +;;=> 65537 +) \ No newline at end of file