Created
March 10, 2016 07:04
-
-
Save drakezhard/16c0ec687e3b5c73b86b to your computer and use it in GitHub Desktop.
clojure map naive implementation
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
(defn my-map [f coll] | |
(loop [acc [] | |
c coll] | |
(if (empty? coll) | |
acc | |
(let [frst (first c) | |
rst (rest c) | |
new-val (conj acc (f frst))] | |
(if (empty? rst) | |
new-val | |
(recur new-val rst)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment