From: Ramakrishnan Muthukrishnan Date: Sun, 20 Jun 2010 04:04:40 +0000 (+0530) Subject: solution to 2.17 X-Git-Url: https://git.rkrishnan.org/frontends/module-simplejson.tests.html?a=commitdiff_plain;h=877b11ba8a56206a44efeadd4cd5d38f7bda31ac;p=sicp.git solution to 2.17 --- diff --git a/src/sicp/ex2_17.clj b/src/sicp/ex2_17.clj new file mode 100644 index 0000000..f58468d --- /dev/null +++ b/src/sicp/ex2_17.clj @@ -0,0 +1,13 @@ +(ns sicp.ex2_17 + (:use [sicp utils ch2_2] + [clojure test])) + +(defn last-pair [lst] + (if (= (length lst) 1) + lst + (last-pair (rest lst)))) + +(deftest test-last-pair-1 + (are [x y] [= x y] + (last-pair (list 1 2 3 4)) (list 4) + (last-pair (list 23 72 149 34)) (list 34))) \ No newline at end of file