Last active
December 15, 2022 09:39
-
-
Save divs1210/bdbb5e761336d4ee5de55e4a6be4736d to your computer and use it in GitHub Desktop.
Clojure eager concatenation
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
(defn eager-cat | |
"Eager concat. | |
Doesn't blow up the stack. | |
Returns a vector." | |
([] | |
[]) | |
([xs] | |
(vec xs)) | |
([xs ys] | |
(into (vec xs) ys)) | |
([xs ys & more] | |
(reduce eager-cat | |
xs | |
(cons ys more)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment