Skip to content

Instantly share code, notes, and snippets.

@divs1210
Last active December 15, 2022 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save divs1210/bdbb5e761336d4ee5de55e4a6be4736d to your computer and use it in GitHub Desktop.
Save divs1210/bdbb5e761336d4ee5de55e4a6be4736d to your computer and use it in GitHub Desktop.
Clojure eager concatenation
(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