Why concatMap instead of concat.map?
Hi, Why does Haskell have a special function called concatMap, rather than people just doing "concat.map"? Is it because concatMap has a more sophisticated implementation than doing just "concat.map"? Cheers, Mark. -- Dr Mark H Phillips Research Analyst (Mathematician) AUSTRICS - smarter scheduling solutions - www.austrics.com Level 2, 50 Pirie Street, Adelaide SA 5000, Australia Phone +61 8 8226 9850 Fax +61 8 8231 4821 Email mark@austrics.com.au
ons 2002-09-11 klockan 04.50 skrev Dr Mark H Phillips:
Hi,
Why does Haskell have a special function called concatMap, rather than people just doing "concat.map"? Is it because concatMap has a more sophisticated implementation than doing just "concat.map"?
I think it's just because it's easier to read/write concatMap f list than (concat.map) f list Regards, Martin -- Martin Norbäck d95mback@dtek.chalmers.se Kapplandsgatan 40 +46 (0)708 26 33 60 S-414 78 GÖTEBORG http://www.dtek.chalmers.se/~d95mback/ SWEDEN OpenPGP ID: 3FA8580B
On Wednesday, 2002-09-11, 09:54, CEST, Martin Norbäck wrote:
ons 2002-09-11 klockan 04.50 skrev Dr Mark H Phillips:
Hi,
Why does Haskell have a special function called concatMap, rather than people just doing "concat.map"? Is it because concatMap has a more sophisticated implementation than doing just "concat.map"?
I think it's just because it's easier to read/write
concatMap f list
than
(concat.map) f list
Hmm, but (=<<) for lists is equivalent to concatMap and f =<< list is, in my opinion, at least easier to read than concatMap f list. But opinions may differ here.
Regards,
Martin
Ciao, Wolfgang
participants (3)
-
Dr Mark H Phillips -
Martin Norbäck -
Wolfgang Jeltsch