Last active
May 10, 2019 19:18
-
-
Save aarkerio/0d756f2e30813ddbc0eb9e75ec83590f to your computer and use it in GitHub Desktop.
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 flat? | |
"true if there is no sequences" | |
[seq] | |
(not-any? (fn [x] (isa? (type x) java.util.List)) seq)) | |
(defn my-flatten | |
"Returns flat sequence" | |
[seq] | |
(if (isa? (type seq) java.util.List) | |
(if (flat? seq) | |
seq | |
(apply concat (map flatten seq))) | |
(list seq))) | |
Test: | |
(my-flatten [1,[7,0],2,[3,8, [7]],4]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment