Created
December 5, 2019 01:08
-
-
Save Solaxun/25449f9f5b9e4962d74d6b431afd04b8 to your computer and use it in GitHub Desktop.
ibid clojure - from Gene Kim's interview on the Functional Geekery podcast.
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
;; couldn't resist after hearing the podcast... | |
(defn ibid [coll] | |
(reduce (fn [res cur] | |
(if (= cur "ibid") | |
(conj res (last res)) | |
(conj res cur))) | |
[(first coll)] | |
(rest coll))) | |
(clojure.test/is | |
(= (ibid ["foo" "ibid" "ibid" "bar" "meh" "ibid" "yay"]) | |
["foo" "foo" "foo" "bar" "meh" "meh" "yay"])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment