Created
April 21, 2014 10:50
-
-
Save sordina/11139214 to your computer and use it in GitHub Desktop.
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
(def x 10) | |
(def y 5) | |
(def z (* x y)) | |
(defn a [b c & d] (+ z x b c | |
(first d))) | |
(a 4 5 10 598798787 876 5765 98798 57679 98797 5765) | |
(defn mult2 [q r] | |
(if (<= q 0) | |
0 | |
(+ r (mult2 (- q 1) r)))) | |
(mult2 10 200) | |
(defn fib [n] | |
(if (= n 0) | |
0 | |
(if (= n 1) | |
1 | |
(+ (fib (- n 1)) | |
(fib (- n 2)))))) | |
(defn fib2 [n a1 a2] | |
(if (= n 0) | |
a1 | |
(recur (- n 1) a2 (+' a1 a2)))) | |
(defn fib3 [n] (fib2 n 0 1)) | |
(fib3 100) | |
(map fib3 (range 10)) | |
(range 12) | |
(map fib (range 10)) | |
(cons 1 [2 4 32 54]) | |
(rest [6 45 76 97]) | |
(empty? []) | |
(defn map2 [f l] | |
(if (empty? l) | |
[] | |
(cons (f (first l)) (map2 f (rest l))))) | |
(map2 fib (range 10)) | |
(defn range2 [n] | |
(if (<= n 0) | |
[] | |
(cons 0 (map2 inc | |
(range2 (- n 1)))))) | |
(cons 0 (map inc (cons 0 (map inc (cons 0 (map inc [])))))) | |
(inc 6) | |
(map2 inc (range 10)) | |
(range2 7) | |
(map2 fib (range2 10)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment