Last active
September 14, 2016 14:29
-
-
Save cmiles74/bc84245ae08f926cb6e6f6c5c4cb55a9 to your computer and use it in GitHub Desktop.
More than one signature
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 third | |
([lst] | |
(third (seq lst) 0)) | |
([lst currentIndex] | |
(if (= (first lst) nil) | |
0 | |
(if (= currentIndex 2) | |
(first lst) | |
(if (< currentIndex 2) | |
(third (rest lst) (+ currentIndex 1))))))) | |
(defn nth-third [lst] | |
(nth lst 2)) | |
(defn loop-third [lst-in] | |
(let [lst (seq lst-in)] | |
(loop [item (first lst) remaining (rest lst) index 0] | |
(if (= index 2) | |
item | |
(recur (first remaining) (rest remaining) (inc index)))))) | |
(defn filter-third [lst-in] | |
(let [lst (seq lst-in)] | |
(first (keep last | |
(filter #(= (first %) 2) | |
(map vector (range) lst)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment