in reply to Re^2: How to get the index of smallest whole number in an array?
in thread How to get the index of smallest whole number in an array?
The explanation by ++JohnGG pretty much nails it.
I might just add, by way of clarification of:
"This construct operates pretty much like grep to filter out any values that don't satisfy the conditions."
grep passes on its arguments unaltered if they satisfy the condition in BLOCK or EXPR:
$ perl -E 'say for grep length, qw{x y z}' x y z
map, on the other hand, passes on whatever the BLOCK or EXPR evaluates to for each argument:
$ perl -E 'say for map length, qw{x y z}' 1 1 1
You may already be aware of this; however, I thought it was worth pointing out: another reader may not be fully across this distinction.
— Ken
|
|---|