4 ms·
I'd replace the inner concatMap (\y -> [x+y]) with a simple map (\y -> x+y), or, if I'm honest, with map (x+). Here's hoping HN doesn't mess up the asterisks..
by omaranto 7y ago
I'd replace the inner concatMap (\y -> [x+y]) with a simple map (\y -> x+y), or, if I'm honest, with map (x+).
Here's hoping HN doesn't mess up the asterisks...
EDIT: I've replaced all asterisks with plus signs, because I couldn't figure out how to protect them from HN.
- tom_mellior 7y agoYeah, I realized that later. It's still more obscure than the version with the list comprehension. In particular, the place where x is introduced is at the very beginning, but the values it can be bound to are at the end of the expression, and that is much less clear than "x <- [0..5]". The rule for asterisks is that they must be followed by whitespace to show up as asterisks, so you just need to format your code nicely :-) x * y works.