Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save flengyel/1446271 to your computer and use it in GitHub Desktop.
Save flengyel/1446271 to your computer and use it in GitHub Desktop.
;; flengyel's solution to Flatten a Sequence
;; https://4clojure.com/problem/28
(fn flat [L] (reduce #(if (coll? %2) ;; if item is collection
(vec (concat %1 (flat %2))) ;; concat current with flat %2
(conj %1 %2)) ;; otherwise conj at top level
[] L)) ;; empty flattened collection, L
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment