Last active
December 11, 2015 18:48
-
-
Save manudatta/4644088 to your computer and use it in GitHub Desktop.
http://www.cs.cmu.edu/~dst/LispBook/book.pdf Chap 3 keyboard exercise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;pg 102. Ex 3.22.c | |
(defn myfun [x y] (list (list x) y)) | |
(myfun 'alpha 'beta) | |
;.d | |
(defn firstp? [ e collection] (= e (first collection)))--clojure uses ? instead of p for predicate (lisp convention) | |
(firstp? 'foo '(foo bar baz)) | |
(firstp? 'boing '(foo bar baz)) -- clojure has false instead of nil | |
;.e | |
(defn mid-add1 [sentence] (list (first sentence) (+ 1 (second sentence)) (last sentence))) | |
(mid-add1 '(take 2 cookies)) | |
;.f | |
(defn f-to-c [F] (/ (* 100 (- F 32)) 180.0))--180.0 otherwise you can get ratio instead of number | |
(f-to-c 132) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment