Re:Python is now the most popular introductory language at t...
by codygman on Monday July 07, 2014 @07:14PM
(#8002156)
Right, I think that once the concept is taught of what mapM does/means it will be easier to keep applying than something like a foreach loop.
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 ;)
Re:Python is now the most popular introductory language at t...
by theaeolist on Tuesday July 08, 2014 @06:33AM
(#8003825)
This is because of lexical issues. You can define aliases for mapM_ and putStrLn and get something more approachable to the lexically challenged.
repeat print ["foo"; "bar"; "etc"]
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.