On 02/28/2017 11:06 PM, Andrew Kirkpatrick wrote:
The zip operator in this case takes two sequences and interleaves them
into a single sequence. It might be useful if you have handy or can
generate a list of keys and a list of values you want to put together
in pairs using => to create a hash t
On 03/01/2017 12:45 AM, Richard Hainsworth wrote:
Todd,
As Andrew explained Z takes two arrays and an operator, eg. =>, or +,
and then 'runs' the operator on the elements of the two lists.
Here, you defined @x as a list of strings. I defined two lists, one of
keys and one of values. Then I zi
Todd,
As Andrew explained Z takes two arrays and an operator, eg. =>, or +,
and then 'runs' the operator on the elements of the two lists.
Here, you defined @x as a list of strings. I defined two lists, one of
keys and one of values. Then I zipped the two together with the =>
operator that a
The zip operator in this case takes two sequences and interleaves them
into a single sequence. It might be useful if you have handy or can
generate a list of keys and a list of values you want to put together
in pairs using => to create a hash table.
Your explicit approach makes sense for readabil
On Wednesday, March 01, 2017 01:01 PM, Todd Chester wrote:
Hi All,
And it even gets more interesting.
It even works with Associative Arrays (Hashes), which I adore!
Interesting how associative arrays don't print in order that they
were entered into the array.
#!/usr/bin/perl6
my @x = ( "a",
Instead of
my %y = ( 'aa'=>"AA", 'bb'=> "BB", 'cc'=>"CC", 'dd'=>"DD" );
in the code below,
I find the following useful for filling an associative array (when
testing and I dont care about the contents)
my %y = Z=> 'AA'..*;
#{aa => AA, bb => AB, cc => AC, dd => AD}
But if the contents matter
Hi All,
And it even gets more interesting.
It even works with Associative Arrays (Hashes), which I adore!
Interesting how associative arrays don't print in order that they
were entered into the array.
#!/usr/bin/perl6
my @x = ( "a", "b", "c", "d" );
print "loop of \@x\n";
for @x.kv -> $inde
On 02/28/2017 01:30 PM, yary wrote:
Maybe using placeholder variables was a bit too much (those variables
with the ^ twigil)
for @a.kv -> $k, $v { say "Value $v has index $k" }
Value g has index 0
Value h has index 1
Value i has index 2
Value j has index 3
Value k has index 4
Hi Yary,
On 02/28/2017 01:25 PM, Elizabeth Mattijsen wrote:
On 28 Feb 2017, at 22:20, ToddAndMargo wrote:
Hi All,
There are times when I want to know th4e index of an array
when I am in a "for @array" loop. I can do it with a
variable outside the for loop and increment it, but
I would line to know k
On Tue, Feb 28, 2017 at 01:20:47PM -0800, ToddAndMargo wrote:
Hi All,
There are times when I want to know th4e index of an array
when I am in a "for @array" loop. I can do it with a
variable outside the for loop and increment it, but
I would line to know know if there is a way to incorporate
On 02/28/2017 01:20 PM, ToddAndMargo wrote:
Hi All,
There are times when I want to know th4e index of an array
when I am in a "for @array" loop. I can do it with a
variable outside the for loop and increment it, but
I would line to know know if there is a way to incorporate
it in the loop com
Maybe using placeholder variables was a bit too much (those variables with
the ^ twigil)
> for @a.kv -> $k, $v { say "Value $v has index $k" }
Value g has index 0
Value h has index 1
Value i has index 2
Value j has index 3
Value k has index 4
> my @a = ( 'g' .. 'k' )
[g h i j k]
> @a.kv
(0 g 1 h 2 i 3 j 4 k)
> for @a.kv { say "Value $^v has index $^i" }
Value g has index 0
Value h has index 1
Value i has index 2
Value j has index 3
Value k has index 4
> On 28 Feb 2017, at 22:20, ToddAndMargo wrote:
>
> Hi All,
>
> There are times when I want to know th4e index of an array
> when I am in a "for @array" loop. I can do it with a
> variable outside the for loop and increment it, but
> I would line to know know if there is a way to incorporate
>
I think the canonical Perl 6 answer is:
for @array.kv -> $index, $value { do something }
Pm
On Tue, Feb 28, 2017 at 01:20:47PM -0800, ToddAndMargo wrote:
> Hi All,
>
> There are times when I want to know th4e index of an array
> when I am in a "for @array" loop. I can do it with a
> variab
Hi All,
There are times when I want to know th4e index of an array
when I am in a "for @array" loop. I can do it with a
variable outside the for loop and increment it, but
I would line to know know if there is a way to incorporate
it in the loop command.
This is my long winded way of doing it i
16 matches
Mail list logo