Newsgroups: perl.perl6.language
From: dataweave...@yahoo.com (Jonathan Lang)
Date: Thu, 12 Feb 2004 20:14:40 -0800 (PST)
Local: Thurs, Feb 12 2004 11:14 pm
Subject: dynamic arguments (was: The Sort Problem)
Jonathan Lang wrote: How about including something similar to <==, but which binds the elements > Luke Palmer wrote: > > I've been thinking about this problem which comes up in my code a lot: > > @sorted = sort { $^a.foo('bar').compute <=> $^b.foo('bar').compute} > > Often the expressions on each side are even longer than that. But one > The problem, then, isn't specific to sort; it happens any time that you > You're looking for something to the effect of: > @sorted = sort { parameters($^a <=> $^b).foo('bar').compute } > That is, you need a way to factor C<.foo('bar').compute> out from each of the list to the various positional parameters? For instance: @sorted = sort {infix:<=> args map {$_.foo('bar').compute}, $^a, $^b } Where @x = $a, $b, $c; is equivelent to routine $a, $b, $c; ===== __________________________________ You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||