Skip to content

Instantly share code, notes, and snippets.

@kohyama
Last active October 19, 2017 09:05
Show Gist options
  • Save kohyama/1708173 to your computer and use it in GitHub Desktop.
Save kohyama/1708173 to your computer and use it in GitHub Desktop.
get a seq of tail seqs for a seq, not including '()
(require '[clojure.test :refer (with-test is run-tests)])
(with-test
(defn tails [coll]
(take-while seq (iterate rest coll)))
(is (= (tails '(:a :b :c))
'((:a :b :c) (:b :c) (:c)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment