This file contains 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
(defn mergestep [l r op] | |
(cond (empty? l) r | |
(empty? r) l | |
:else | |
(let [fl (first l) | |
fr (first r)] | |
(if (op fl fr) | |
(cons fl (mergestep (rest l) r op)) | |
(cons fr (mergestep l (rest r) op)))))) | |
This file contains 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
(defn finditemwithoutpair [data] | |
(if (= 1 (count data)) | |
(first data) | |
(if (= (first data) (second data)) | |
(finditemwithoutpair (drop 2 data)) | |
(first data)))) |
This file contains 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
(defn qpart [data p] | |
(reduce (fn [acc item] | |
(cond | |
(< item p) (assoc acc :left (conj (:left acc) item)) | |
(> item p) (assoc acc :right (conj (:right acc) item)) | |
:else (assoc acc :ps (conj (:ps acc) item)))) | |
{:left [] :right [] :ps []} data)) | |
This file contains 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
(defn gdc [x y] | |
(if (= x y) | |
x | |
(if (> x y) | |
(recur (- x y) y) | |
(recur (- y x) x)))) | |
(gdc 10, 100) ; 10 |
This file contains 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
(defn fib-iter [a b n] | |
(if (zero? n) | |
b | |
(recur (+ a b) a (dec n)))) | |
(defn fib [n] | |
(fib-iter 1 0 n)) | |
(fib 40) ;102334155 |
This file contains 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
Links: | |
* http://blog.zachorr.com/nginx-setup/ |
This file contains 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
(defn pascaltriangle-iter [row col] | |
(if (or (= col 1) (= col row)) | |
1 | |
(+ | |
(pascaltriangle-iter (- row 1) (- col 1)) | |
(pascaltriangle-iter (- row 1) col)))) | |
(defn pascaltriangle-row [row] | |
(for [i (range 1 (+ 1 row))] | |
(pascaltriangle-iter row i))) |
This file contains 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
Verifying myself: My Bitcoin username is +podviaznikov. https://onename.io/podviaznikov |
I hereby claim:
- I am podviaznikov on github.
- I am podviaznikov (https://keybase.io/podviaznikov) on keybase.
- I have a public key whose fingerprint is ED55 74C1 1394 8860 7EA1 C228 879F 60AE EC4D D532
To claim this, I am signing this object: