eyepopslikeamosquito has asked for the wisdom of the Perl Monks concerning the following question:

Though I'm too embarassed to ask such a simple question on p6l, I couldn't find any Perl 6 list of lists example code. :-( ... So dear monks, how should I write the perl 5 code below in perl 6?

my @z = ( [ 'a1', 'a2' ], [ 'b1', 'b2', 'b3' ] ); for my $r (@z) { print "@$r\n" }

Replies are listed 'Best First'.
Re: perl 6 list of lists example code sought
by stvn (Monsignor) on Apr 06, 2005 at 15:21 UTC

    AFAIK, mostly all that changes is the for loop, and I suspect that you wont need to explicitly de-reference the nested array either. So you code might look like this:

    for @z -> $r { say $r }

    -stvn
Re: perl 6 list of lists example code sought
by tlm (Prior) on Apr 06, 2005 at 14:31 UTC

    Try here.

    the lowliest monk

      Have you tried looking through it? Maybe you could find the snippet and post it here, so the OP doesn't have to wade through almost a thousand single-line text files, all called Listing00#.txt ...

        From Perl 6 Now:

        ## Chapter 7 Listing 024 # Loop over the mod file datastructures, splicing each note encountere +d into # the wav data use PDL; use Perl6::Variables; my $offset = 0; # Output wav data offset my $offset_step = $sample_rate / 10; # 10 times a second notes may ch +ange for my $position (@positions) { for my $frame ( 0 .. 63 ) { for my $channel ( 0 .. 3 ) { my $note = @patterns[$position][$frame][$channel]; if($note->{sample}) { # the note for this channel changed my $scaled_sample = scale_sample($note, \@samples); my $scaled_sample_length = $scaled_sample->dim(0); $audio->range( [$channel, $offset], [0, $scaled_sample_length] ) .= $scaled_sample; } } $offset += $offset_step; } } ## Chapter 8 Listing 070 # @array_of_arrays will always contain exactly 5 array references afte +r this, # assuming @array_of_arrays and @array1 through @array5 have been decl +ared # Perl 5 my @array_of_arrays = (\@array1, \@array2, \@array3, \@array4); push @array_of_arrays, \@array5; # Perl 6 my @array_of_arrays = (@array1, @array2, @array3, @array4); push @array_of_arrays, @array5;

        Update: One more example added.

        the lowliest monk