Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: AoA Selective Element Substitution

by shigetsu (Hermit)
on Jul 20, 2007 at 22:48 UTC ( [id://627902]=note: print w/replies, xml ) Need Help??


in reply to AoA Selective Element Substitution

Albeit I concur mostly with FunkyMonk, just for the sake of completeness and something to play with (not everything here presented is a solution, and not even suitable sometimes (some of it is intentionally flawed - one should examine the output before using it); it tries to illustrate to a certain extent what is possible by using map):

#!/usr/bin/perl use strict; use warnings; use Data::Dumper qw(Dumper); { list_dump(sub { map { $_->[0] < 5 } @{set()} } ); list_dump(sub { map { $_->[2] < 5 ? $_ : () } @{set()} } ); list_dump(sub { map { [ map { $_ + 1 } @$_ ] } @{set()} } ); list_dump(sub { map { local $_ = $_; $_->[0] = 7; $_ } @{set()} } ); list_dump(sub { map { my @copy = @$_; [ map { $_ *= 2 } @copy ] +} @{set()} } ); sub list_dump (&) { my @list = $_[0]->(); print Dumper \@list; } sub set { return [ [1,2,3],[4,5,6] ]; } }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-04-26 04:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found