Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: How would you code this?

by kennethk (Abbot)
on Apr 06, 2016 at 20:14 UTC ( [id://1159753]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $modified = reduce{
        my( $x1, $y1, $x2, $y2 ) = ( @{ @{ $a }[ -1 ] }, @$b );
         $x2 < $x1 ? pop @{ $a } : push @{ $a }, $b;
        $a;
    } [ shift @points ], @points;
    
  2. or download this
    my $i = 1;
    while ($i < @points) {
    ...
            $i++;
        }
    }
    
  3. or download this
    my $modified = [];
    for my $point (@points) {
    ...
            push @$modified, $point;
        }
    }
    
  4. or download this
    my @m;
    @m&&$m[-1][0]>$_->[0]?pop @m:push @m,$_ for @points;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1159753]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-19 17:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found