Front page | perl.perl6.language |
Postings from March 2005
splat operator and context
Thread Next
From:
Aldo Calpini
Date:
March 9, 2005 03:12
Subject:
splat operator and context
Message ID:
422EDA01.8070000@perl.it
I was trying to implement unary * (list flatten or "splat" operator) in
pugs yesterday, and I came to the conclusion that I really don't grok
how context works in Perl6 (I also really don't grok Haskell, but this
is another story...).
if I understand correctly, all these are equivalents:
my @a = 1,2,3;
my @a = (1,2,3);
my @a = list 1,2,3;
my @a = [1,2,3]; # or does it make @a[0] = (1,2,3)?
and all these are too (they make $a a reference to an array):
my $a = 1,2,3;
my $a = (1,2,3);
my $a = list 1,2,3;
my $a = [1,2,3];
I'm not sure what the following do (assign 1 to $a maybe?):
my $a = *@a;
my $a = *(1,2,3); # or is this a syntax error?
my $a = *(list 1,2,3);
my $a = *[1,2,3];
and I have absolutely no clue about the following:
my *$a = @a;
my *$a = *@a;
my *$a = (1,2,3);
my *$a = [1,2,3];
thanks for any help.
cheers,
Aldo
Thread Next
-
splat operator and context
by Aldo Calpini