|
|
|
|
|
by achal
4359 days ago
|
|
My first reaction to this was that this was definitely less understandable, but I realized there were two pieces to this. One is banal - mapM_ and putStrLn are not near as simple as `for' and `print' (the latter have English meanings directly). The second piece is interesting: Is something of the sort "<mapfn> <printfn> <list>" easier to explain to someone who's new to programming than "<foreach> <print>"? I've always thought the latter was easier to understand, but I'm curious which one someone who has no previous programming experience would grasp more immediately. |
|
The reason being that "<mapfn> <somefn> <list>" is more declarative, whereas the foreach loop is ambiguous. Something we often take for granted is how hard it was at first to come up with what exactly we need to do or mutate inside that loop to build the right result.
If nothing else, there is interesting discussion to be had ;)