Simon Cozens wrote:
I don't understand this, on several levels. The lowest level on which I don't understand it is that testing whether an array is full of threes: @array & 3
Err...that's not what that does. What you wrote creates a scalar value that superimposes the scalar values C< \@array > and C< 3 >.
To test if an array is full of 3's you'd write: all(@array) == 3
makes sense, but how do you test if all of its elements are more than six? @array & { $^a > 6 } # ?
No. What you wrote is the superposition of C< \@array > and (effectively) C< sub($a){$a>6} >. To test if an array is full of greater-than-6's you'd write: all(@array) > 6
If you can't do the latter with the same operator as the former, why have the operator at all?
The operator is for composing superpositions from separate elements. Such as: $x & $y & $z == 3 # all three variables equal 3 $x & $y & $z < 6 # all three variables greater than 6 $x & $y | $z < 6 # either $x and $y greater than 6, or $z greater than 6
Suddenly, @array.all?({ |$a| $a > 6 }) seems a lot more appealing. :)
More appealing than: all(@array) > 6 ??? No wonder you put a smiley there. ;-) Damian