Front page | perl.perl6.language |
Postings from May 2005
The [] metaoperator
Thread Previous
|
Thread Next
From:
Autrijus Tang
Date:
May 14, 2005 07:54
Subject:
The [] metaoperator
Message ID:
20050514145338.GA79539@aut.dyndns.org
On Sat, May 14, 2005 at 10:56:29PM +1000, Damian Conway wrote:
> 8. To verify the monotonicity of a sequence:
>
> $is_monotonic = [<] @numbers;
Hey. Does this mean that the [] metaoperator folds with the
associativity of the operator inside it?
That is, if the operator inside is right-associative, it functions as
foldr; if the operator is left-associative, it functions as a foldl; and
if the operator is chain-associative like <, it assumes the special,
short-circuiting chained-folding semantic?
[>] 1, 2, 3; # 1 > 2 > 3 # 3 is not evaluated
[**] 1, 2, 3; # 1 ** (2 ** 3)
[+] 1, 2, 3; # (1 + 2) + 3
If so, should I send patches to S03, or is it already in the works?
Finally, what does this mean?
say [x];
Is it a repeating metaoperator on an empty list, or a single-element
array reference that contains the return value of calling &x()?
Thanks,
/Autrijus/
Thread Previous
|
Thread Next