Forked from anonymous/flengyel-4clojure-solution28.clj
Created
December 8, 2011 06:18
-
-
Save flengyel/1446271 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
;; 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