Re: .map/.reduce with larger arity

2009-03-25 Thread Moritz Lenz
Leon Timmermans wrote: > I would propose there to be one difference between for an map: map > should bind its arguments read-only, for should bind them read-write. > That would make at least one bad practice an error. That sounds very impractical, because the ro/rw distinction is part of the sign

Re: .map/.reduce with larger arity

2009-03-25 Thread Moritz Lenz
Leon Timmermans wrote: > I would propose there to be one difference between for an map: map > should bind its arguments read-only, for should bind them read-write. > That would make at least one bad practice an error. That sounds very impractical, because the ro/rw distinction is part of the sign

Re: .map/.reduce with larger arity

2009-03-25 Thread Mark J. Reed
On Wed, Mar 25, 2009 at 6:20 PM, Leon Timmermans wrote: > I would propose there to be one difference between for an map: map > should bind its arguments read-only, for should bind them read-write. > That would make at least one bad practice an error. Why is r/w map a bad practice if r/w for is no

Re: .map/.reduce with larger arity

2009-03-25 Thread Leon Timmermans
On Tue, Mar 10, 2009 at 12:09 AM, Larry Wall wrote: > > Yes, the only difference between C and C is that you can > only use C at the start of a statement.  But we're more liberal > about where statements are expected in Perl 6, so you can say things > like: > >    my @results = do for @list -> $x

Re: .map/.reduce with larger arity

2009-03-10 Thread Daniel Ruoso
Em Seg, 2009-03-09 às 12:24 -0700, Larry Wall escreveu: > On Mon, Mar 09, 2009 at 02:40:43PM -0300, Daniel Ruoso wrote: > : ... $capture ~~ $signature ...; > : my $args_matched = @($/).elems; > : &code.(|$/); > That API still would not tell the match whether signature must match the > entire

Re: .map/.reduce with larger arity

2009-03-10 Thread Larry Wall
On Tue, Mar 10, 2009 at 07:46:51PM +1300, Martin D Kealey wrote: : I'd like to be able to use grep, map, etc in a currying fashion. Can I do: : : my &square_list := -> $x { $x * $x }.map(); my &square_list := &map.assuming(-> $x { $x * $x}); : And if so, what is the signature of &squar

Re: .map/.reduce with larger arity

2009-03-09 Thread Martin D Kealey
On Mon, 9 Mar 2009, Larry Wall wrote: > the only difference between C and C is that you can only use > C at the start of a statement. But we're more liberal about where > statements are expected in Perl 6, so you can say things like: > > my @results = do for @list -> $x {...}; > my @resul

Re: .map/.reduce with larger arity

2009-03-09 Thread Larry Wall
On Mon, Mar 09, 2009 at 11:38:29AM -0500, Patrick R. Michaud wrote: : On Sun, Mar 08, 2009 at 09:31:19PM -0700, Larry Wall wrote: : > On Sun, Mar 08, 2009 at 09:36:17PM +0100, Moritz Lenz wrote: : > : But both pugs and rakudo respect the arity of the code ref passed to it, : > : so that (1..6).map(

Re: .map/.reduce with larger arity

2009-03-09 Thread Larry Wall
On Mon, Mar 09, 2009 at 02:40:43PM -0300, Daniel Ruoso wrote: : Em Dom, 2009-03-08 às 21:31 -0700, Larry Wall escreveu: : > I think the basic rule has to be simply can the signature bind to : > the remaining arguments. If not, we get a warning on unused arguments. : : Just to put here an idea I s

Re: .map/.reduce with larger arity

2009-03-09 Thread Daniel Ruoso
Em Dom, 2009-03-08 às 21:31 -0700, Larry Wall escreveu: > I think the basic rule has to be simply can the signature bind to > the remaining arguments. If not, we get a warning on unused arguments. Just to put here an idea I sent on irc... What if Signature.ACCEPTS set $/ with the matched argumen

Re: .map/.reduce with larger arity

2009-03-09 Thread Patrick R. Michaud
On Sun, Mar 08, 2009 at 09:31:19PM -0700, Larry Wall wrote: > On Sun, Mar 08, 2009 at 09:36:17PM +0100, Moritz Lenz wrote: > : But both pugs and rakudo respect the arity of the code ref passed to it, > : so that (1..6).map({$^a + $^b + $^c}) returns the list (6, 15), which is > : very nice and very

Re: .map/.reduce with larger arity

2009-03-08 Thread Larry Wall
On Sun, Mar 08, 2009 at 09:36:17PM +0100, Moritz Lenz wrote: : Currently the spec says: : : C returns a lazily evaluated list which is comprised of : the return value of the expression, evaluated once for every : one of the C<@values> that are passed in. : : But both pugs and rakudo respect th

.map/.reduce with larger arity

2009-03-08 Thread Moritz Lenz
Currently the spec says: C returns a lazily evaluated list which is comprised of the return value of the expression, evaluated once for every one of the C<@values> that are passed in. But both pugs and rakudo respect the arity of the code ref passed to it, so that (1..6).map({$^a + $^b + $^c})