in reply to Re^3: my array is almost a hash, but keys are not unique.
in thread my array is almost a hash, but keys are not unique.

In golf you still have to get the ball in the hole generate the correct result. Bugs in golfed Perl are still bugs. ;)

In the second paragraph of the Auto increment and Auto decrement section of perlop it says:

Note that just as in C, Perl doesn't define when the variable is incremented or decremented. You just know it will be done sometime before or after the value is returned. This also means that modifying a variable twice in the same statement will lead to undefined behaviour.

True laziness is hard work
  • Comment on Re^4: my array is almost a hash, but keys are not unique.

Replies are listed 'Best First'.
Re^5: my array is almost a hash, but keys are not unique.
by ELISHEVA (Prior) on Apr 07, 2009 at 01:30 UTC
    Thanks!

    Best, beth

Re^5: my array is almost a hash, but keys are not unique.
by Boldra (Curate) on Apr 07, 2009 at 14:50 UTC
    Yes, thank you very much! I did actually use ELISHEVAS golf code as a basis for my own, now I'll review. As mentioned elsewhere in this thread, I don't like the C style loops, which was one of the reasons I picked it. My version was something like this:
    my %out; my @in = @{ $in }; my $i = 0; while ( $i < $#in ) { push( @{ $out{ $in[ $i++ ] } }, $in[ $i++ ] ) ; } return \%out;
    Which was basically ELISHIVAS, with dereferencing and no postfix while.


    - Boldra