Skip to content

Instantly share code, notes, and snippets.

@Solaxun
Created December 5, 2019 01:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Solaxun/25449f9f5b9e4962d74d6b431afd04b8 to your computer and use it in GitHub Desktop.
Save Solaxun/25449f9f5b9e4962d74d6b431afd04b8 to your computer and use it in GitHub Desktop.
ibid clojure - from Gene Kim's interview on the Functional Geekery podcast.
;; 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