need for concatMap in nested Haskell maps -



need for concatMap in nested Haskell maps -

i don't understand why concatmap, rather map, needed in this:

expand :: [[int]] -> [[int]] expand xs = concatmap (\a -> (map (\b -> a++b) [[1],[2],[3]])) xs

don't , b each pick simple list in respective assignments, a++b concatenation of these lists should list?

would appreciate insight ...

map preserves number of elements in input list, can't utilize since want create 3 elements in output every list in input list. concatmap allows returning list incorporated output list. inner map creates 3 lists input list, since returns list of lists each input list need remove layer of nesting.

haskell

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -