-
-
Save luxbock/55ea567166081af107fd7a22582bf8c2 to your computer and use it in GitHub Desktop.
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
(defnav REST [] | |
(select* [this coll next-fn] | |
(next-fn | |
(if (vector? coll) | |
(subvec coll 1) | |
(rest coll)))) | |
(transform* [this coll next-fn] | |
(if (seq? coll) | |
(cons (first coll) | |
(next-fn (rest coll))) | |
(into (conj (empty coll) (first coll)) | |
(next-fn (rest coll)))))) | |
(select-one REST [1 2 3 4 5]) ;; => [2 3 4 5] | |
(transform [REST ALL] inc [1 2 3 4 5]) ;; => [1 3 4 5 6] | |
(transform [REST ALL] inc #{1 2 3}) ;; => #{1 4 3} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment