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 width 50) | |
(def height 50) | |
(defn populated? [pos] | |
true) | |
(defn unpopulated? [pos] | |
false) | |
(defn neighbors [pos] |
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
(import '(System.Reflection Assembly)) | |
(Assembly/LoadWithPartialName "System.Xml") | |
(import '(System.Xml XmlDocument)) | |
(import '(System DateTime)) | |
(def yaml "\ntype: %s\nname: %s\ncreated at: %s\naccepted at: %s\n") | |
(def csv "%s;%s;%s;%s\n") | |
(def types '("release" "feature" "bug")) | |
(def xml (doto (XmlDocument.) (. Load "11621.xml"))) |
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
#(loop [f %1 s %2 c ()] | |
(if (or | |
(empty? f) | |
(empty? s)) | |
(reverse c) | |
(recur (rest f) (rest s) (conj c (first f) (first s))))) |
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
#(loop [coll %1 n %2 c ()] | |
(if (empty? coll) | |
(reverse c) | |
(recur (rest coll) n (into c (repeat n (first coll)))))) |
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
;http://4clojure.com/problem/42 | |
#(loop [n % f 1] | |
(if (= n 1) | |
f | |
(recur (dec n) (* f n)))) |
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
#(loop [col % c ()] | |
(cond (empty? col) (reverse c) | |
(= (first col) (first c)) (recur (rest col) c) | |
:else (recur (rest col) (cons (first col) c)))) |
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
;http://4clojure.com/problem/34 | |
#(loop [from %1 to %2 c ()] | |
(if (= from to) | |
(reverse c) | |
(recur (inc from) to (conj c from)))) |
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
;http://4clojure.com/problem/32 | |
#(loop [col % c ()] | |
(if (empty? col) | |
(reverse c) | |
(recur (rest col) | |
(cons (first col) (cons (first col) c))))) |
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
;http://4clojure.com/problem/26 | |
#(loop [n % seq []] | |
(letfn [(fib [x] | |
(if (<= x 2) | |
1 | |
(+ (fib (- x 2)) (fib(- x 1)))))] | |
(if (= n 0) | |
seq | |
(recur (dec n) (cons (fib n) seq))))) |
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
;http://4clojure.com/problem/23 | |
#(loop [coll % stk []] | |
(if (empty? coll) | |
stk | |
(recur (next coll) (cons (first coll) stk)))) |