in reply to Re^2: hash and array
in thread hash and array

What does the expression %hash{@array} >>++ evaluate to in list context? With sigils just part of the name, I don't have any feel for this yet. But I suppose the evaluation is a property of the >>++ op.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^4: hash and array
by mrborisguy (Hermit) on May 22, 2005 at 20:12 UTC

    %hash{@array} >>++
    would be pretty much the same as
    %hash{$_}++ for @array
    if I understand correctly. Is that what you are asking? I think >> applies the operation to all of the elements of the array to the left of the >>. The best example of the >> and << things (I don't know what they are called... maybe not operators), would be
    @added = @array1 >>+<< @array2;
    which is like
    ## p5 code, I'm not completely fluent in p6 yet... for ( my $i = 0; i < $#array1; i++ ) { $added[ $i ] = $array1[ $i ] + $array2[ $i ] }

    -Bryan

      %hash{$_}++ for @array

      I'd expect it to be more like map instead of for, so that you can do

      @old = %hash{@keys} >>++;
      but I'm 100% guessing.

      ihb

      See perltoc if you don't know which perldoc to read!

        You know what, I can't even say. I was going to try it out, see what it did, but I can't even get:

        %hash{ @keys } >>++;

        to run, much less

        @old = %hash{ @keys } >>++;

        So I don't know what the deal is. I'm running Pugs, and I updated it from svn just today, so maybe they just haven't implimented it yet. I'm pretty sure I was there when japhy asked the question on #perl6, so I'm fairly confident the syntax must be right. What I'm trying to say, I guess, is that I just don't know enough to answer your question! (Man, I hate when that happens!)

        -Bryan