I understand the equivalent to flatMap
in Scala is mapcat in Clojure.
I have an inkling that mapcat
in clojure only works with sequences, unli
They seem very similar and appear to work on the same kind of things. From looking at the documentation and examples I can't see a functional difference.
mapcat
works on sequences, and just about every clojure data type can be a sequence. If you pass something that is not already a seq
to mapcat
it will call seq on it automatically, so in practice you can pass just about all clojure values to mapcat. If you want to iterate over a tree you would need to call prewalk
or postwalk
to specify the traversal order.