Last active
October 1, 2017 14:20
-
-
Save lagenorhynque/1c39e13c3946c175386505950e0efa67 to your computer and use it in GitHub Desktop.
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
| user> (defn enum | |
| ([fst] | |
| (iterate inc fst)) | |
| ([fst snd] | |
| (iterate #(+ % (- snd fst)) fst)) | |
| ([fst snd lst] | |
| (range fst (inc lst) (- snd fst)))) | |
| #'user/enum | |
| user> (take 10 (enum 1)) ; take 10 [1..] | |
| (1 2 3 4 5 6 7 8 9 10) | |
| user> (take 10 (enum 1 3)) ; take 10 [1, 3..] | |
| (1 3 5 7 9 11 13 15 17 19) | |
| user> (enum 1 3 21) ; [1, 3..21] | |
| (1 3 5 7 9 11 13 15 17 19 21) | |
| user> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment