by Sharlin · 8y ago · 0 comments
With the caveat that `flatten` is recursive and can handle a mix of collections and non-collections, while `mapcat` is non-recursive and every value returned by the mapcatted function must be a collection or nil.
(Identity returns its argument.)
(flatten [1 [2 3] [[4 5 6]]])
> [1 2 3 4 5 6]
(mapcat identity [1 [2 3] [[4 5 6]]])
> IllegalArgumentException Don't know how to create ISeq from: java.lang.Long
(mapcat identity [[1] [2 3] [[4 5 6]]])
> (1 2 3 [4 5 6])
(flatten [nil [1 2 3]])
> (nil 1 2 3)
(mapcat identity [nil [1 2 3]])
> (1 2 3)