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

(Update: Verified.) The Perl 6 code for that be %hash{@array} >>++; which I think is just freaking awesome.

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Replies are listed 'Best First'.
Re^3: hash and array
by Zaxo (Archbishop) on May 22, 2005 at 20:05 UTC

    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

      %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!

Re^3: hash and array
by Anonymous Monk on May 23, 2005 at 07:07 UTC
    just freaking awesome
    beep poop poop beep poop poop beeeep. The results are in, it is freaking awsome :)