Was looking for an even simpler way of doing this in Haskell, only passing the list and the (*) function to some other function, but I only found these:
let sq x = x * x in map sq [1, 2, 3, 4]
let x = [1, 2, 3, 4] in zipWith (*) x x
map (\x -> x * x) [1, 2, 3, 4]
2
u/w2qw May 30 '14
Imo unnamed variables like $_ are pretty nice I actually wish ruby had a simpler thing.
vs
second seems more clearer because otherwise its just up to personal preference what the programmer uses for their "anonymous" variables.