The fundamental problem here seems to be the imprint of Perl's
behaviour on the mental model. Assigning arrays flattens them into a
list of their contents, which then gets used as input to the
assignment. That means that more complicated structures, such as
arrays of arrays need some faking.
Raku
On 2021-01-19 2:18 p.m., Brian Duggan wrote:
Hi Folks,
I ran into this situation today, which seems counterintuitive:
my @one = 1,2,3;
my @two = 4,5,6;
my @both = @one,@two;
my @first = @both[0];
say @one.raku;
say @first.raku;
output:
[1, 2, 3]
[[1, 2, 3],]
I
Hi Brian (and Bruce),
Just a short note to say that we had a conversation entitled "Extra .
needed" on this mailing list a few weeks ago, for which the solution
(per Brad Gilbert) was a sort of "double-dereferencing" (for lack of a
better terminology):
Food for thought...
Python:
one = 1,2,3
two = 4,5,6
both = one,two
first = both[0]
print(one) # (1, 2, 3)
print(first) # (1, 2, 3)
Python's `=` operator is like Raku's `:=`.
my @one := 1,2,3;
my @two := 4,5,6;
my @both := @one,@two;
my @first := @both[0];
say @one.raku; # (1, 2, 3)
say
Thanks everyone for the thoughtful replies.
I think this helped me the most --
On Tuesday, January 19, Vadim Belman wrote:
> We have a documentation section on this:
> https://docs.raku.org/language/list#Itemization
"itemization in Arrays is assumed"
...
"It was decided all those
> On Jan 19, 2021, at 12:18 PM, Brian Duggan wrote:
>
> Hi Folks,
>
> I ran into this situation today, which seems counterintuitive:
>
> my @one = 1,2,3;
> my @two = 4,5,6;
> my @both = @one,@two;
> my @first = @both[0];
> say @one.raku;
> say @first.raku;
>
> output:
>
> [1, 2, 3]
Hi,
I would like to give a perspective a bit different to what yary provided.
Your example here can be golfed down to:
my $a = [1,2,3];
my @v = $a;
say @v; # [[1,2,3],]
The reason for this behavior is $a being a scalar container. Correspondingly,
when you assign it to @v the assignment op
On 1/19/21 10:42 AM, yary wrote:
Let's dig in a little
my @one = 1,2,3;
my @two = 4,5,6;
my @both = @one,@two;
at this point @both is an array containing two arrays
> dd @both
Array @both = [[1, 2, 3], [4, 5, 6]]
Showing that assigning into an array variable gives an array, each
Let's dig in a little
my @one = 1,2,3;
my @two = 4,5,6;
my @both = @one,@two;
at this point @both is an array containing two arrays
> dd @both
Array @both = [[1, 2, 3], [4, 5, 6]]
Showing that assigning into an array variable gives an array, each element
of which can itself be an array.
(my $x, undef, my $y) = 1 .. 3; parses to my ($x, undef, $y) = 1 .. 3
and always has as far as I know, so please share your hallucinogens
with the list:)
Sadly, the hallucinogens are essential, not external. But I'm pretty
sure those are two different parse trees.
They have the same
Mark J. Reed wrote:
I distinctly recall having to do things like (my $a, undef, my $b) to
avoid errors because you can't assign to undef. Maybe I'm just
hallucinating.
Maybe :)
$ perl -Mstrict -e 'my ($a, undef, $b) = 1..3; print $a $b\n;'
1 3
This works as far back as v5.6.0 (which is the
Vincent Foley wrote:
Hello everyone,
I was toying around with Pugs and I tried the following Perl 5 list
assignment
my ($a, undef, $b) = 1..3;
Which gave me the following error message:
Internal error while running expression:
***
Unexpected ,
expecting word
On Wed, Nov 15, 2006 at 10:28:41AM -0600, Jonathan Rockway wrote:
: For reference, this sort of operation works if you write it on two
: lines, like:
:
: my ($a, $b);
: ($a, undef, $b) = 1..3;
: say $a is 1 and $b is 3;
:
: I'll look around in the source and see if I can make this
On Tue, Nov 14, 2006 at 10:15:42PM -0500, Vincent Foley wrote:
: Hello everyone,
:
: I was toying around with Pugs and I tried the following Perl 5 list
: assignment
:
: my ($a, undef, $b) = 1..3;
:
: Which gave me the following error message:
:
: Internal error while running expression:
:
On 11/14/06, Vincent Foley [EMAIL PROTECTED] wrote:
I was toying around with Pugs and I tried the following Perl 5 list assignment
my ($a, undef, $b) = 1..3;
Huh. I didn't think that worked in Perl 5, either. What am I misremembering?
I distinctly recall having to do things like (my $a,
On 11/15/06, Mark J. Reed [EMAIL PROTECTED] wrote:
On 11/14/06, Vincent Foley [EMAIL PROTECTED] wrote:
I was toying around with Pugs and I tried the following Perl 5 list assignment
my ($a, undef, $b) = 1..3;
Huh. I didn't think that worked in Perl 5, either. What am I misremembering?
I
my ($a, undef, $b) = 1..3;
Huh. I didn't think that worked in Perl 5, either. What am I
misremembering? I distinctly recall having to do things like (my $a, undef,
my $b) to avoid errors because you can't assign to undef. Maybe I'm just
hallucinating.
Are you remembering this:
my
On Nov 15, 2006, at 12:04 PM, Mark J. Reed wrote:
On 11/14/06, Vincent Foley [EMAIL PROTECTED] wrote:
I was toying around with Pugs and I tried the following Perl 5
list assignment
my ($a, undef, $b) = 1..3;
Huh. I didn't think that worked in Perl 5, either. What am I
On Wed, Nov 15, 2006 at 05:41:24PM +, Ævar Arnfjörð Bjarmason wrote:
On 11/15/06, Mark J. Reed [EMAIL PROTECTED] wrote:
On 11/14/06, Vincent Foley [EMAIL PROTECTED] wrote:
I was toying around with Pugs and I tried the following Perl 5 list
assignment
my ($a, undef, $b) = 1..3;
On Wed, Nov 15, 2006 at 11:17:57PM +, Nicholas Clark wrote:
I thought that allowing undef in my ($a, undef, $b) came in around 5.004ish,
but I can't find it in perldelta, and I don't have a version compiled to
test with (or any quick way to compile them, given that pretty much only
AIX is
On 11/15/06, Ævar Arnfjörð Bjarmason [EMAIL PROTECTED] wrote:
On 11/15/06, Mark J. Reed [EMAIL PROTECTED] wrote:
On 11/14/06, Vincent Foley [EMAIL PROTECTED] wrote:
I was toying around with Pugs and I tried the following Perl 5 list
assignment
my ($a, undef, $b) = 1..3;
Huh. I didn't
On 11/15/06, Dave Mitchell [EMAIL PROTECTED] wrote:
$ perl-5322 -we'my ($x,undef,$y) = 1..3'
Can't declare undef operator in my at -e line 1, near ) =
Execution of -e aborted due to compilation errors.
$ perl545 -we'my ($x,undef,$y) = 1..3'
$
Ah-hah! So I'm not crazy! Necessarily, anyway.
22 matches
Mail list logo