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

Re^2: Perl6 Contest #2: P6 That Doesn't Look Like P5

by kelan (Deacon)
on Jun 03, 2005 at 13:09 UTC ( [id://463250]=note: print w/replies, xml ) Need Help??


in reply to Re: Perl6 Contest #2: P6 That Doesn't Look Like P5
in thread Perl6 Contest #2: P6 That Doesn't Look Like P5

You can always simulate your own n-ary map using gather:

gather { for @loop Y @pos -> $arr, $i { take $a[ $i ]; } }
Although allowing map to take multiple items from the list at once would be nicer, and it's something I've wanted rather often.

Replies are listed 'Best First'.
Re^3: Perl6 Contest #2: P6 That Doesn't Look Like P5
by iblech (Friar) on Jun 03, 2005 at 18:18 UTC
    Although allowing map to take multiple items from the list at once would be nicer, and it's something I've wanted rather often.

    Sure, works in current Pugs! :)

    @result = map { $^a + $^b } 1,2,3,4; # 3,7 @result = map -> $a, $b { $a + $^b } 1,2,3,4; # 3,7 # And: $result = reduce { $^a + $^b * $^c } 1,2,3,4,5; # same as $result = (1 + 2 * 3) + 4 * 5; # i.e. # 27

    --Ingo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-25 15:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found