Created
November 30, 2017 09:29
-
-
Save raven-rock/3433e8893442b1d8372708f2d829d6ab to your computer and use it in GitHub Desktop.
Clojure inclusive-range function
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
(defn inclusive-range | |
"Like range, but STOP (when defined) is inclusive. Leads to simpler code | |
without all the inc'ing etc. E.g., | |
(inclusive-range 1 5) #=> (1 2 3 4 5)" | |
([] (range)) | |
([stop] (range (inc stop))) | |
([start stop] (range start (inc stop))) | |
([start stop step] (range start (inc stop) step))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment