Created
January 26, 2011 20:30
-
-
Save fogus/797389 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
(defn iota [t nxt stop y] | |
(take-while stop (iterate #(t (nxt %)) y))) | |
(iota identity inc #(< % 10) 1) | |
(def upto (fn [end start] | |
(iota identity inc #(< % end) start))) | |
(def downto (fn [end start] | |
(iota identity dec #(> % end) start))) | |
(upto 10 1) | |
(downto 10 20) | |
(defn to [start end] | |
(if (<= start end) | |
(upto end start) | |
(downto end start))) | |
(to 10 20) | |
(to 20 10) | |
(to 5 -5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment