Pathologically Eclectic Rubbish Lister | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Maybe it's just that I was a math major, or got too close to those whacky Haskell nuts, but map has always seemed a very natural metaphor for me. (It's the natural extension of a function on a space A to the space An)
However, this (map is natural instead of foreach) is only true when the expression inside the map isn't itself accumulating side-effects; e.g. the following useage of map doesn't seem natural: However, this useage seems quite natural: I guess you could also distinguish these two cases by noting that one calls map in void context whereas the other does not; while that's true, I think I'd still prefer over: Even though I like map, because I'm not completely comfortable with the idea of depending on a certain execution order for map, even though I know it has one. When I'm thinking in a linear, this-gets-executed-then-this mode, map rarely makes sense. map does however make sense as a higher-order function, and when I'm thinking like that it's quite natural. (Of course, all style niceties get completely discarded inside JAPHs)
--
In reply to Re^2: Things I Don't Use in Perl
by fizbin
|
|