>Damian Conway [mailto:[EMAIL PROTECTED]] wrote:
>
>You *could* instead consider reversing the arguments to all the list
>manipulation operators:
>
>       @result = map @data { mapping() }
>       @result = grep @data { selector() };
>       @result = sort @data { comparison() };
>       @result = reduce @data { combinator() };
>

I would love this. From an OO point of view, it looks much more natural imho
to think on map and friends as list methods that take block arguments than
as block methods that take arrays as arguments.

In other words:

     @result = @data.map(&mapping)

looks better than:

     @result = &mapping.map(@data)


>Then you would have the possibility of:
>
>       @result = map @data -> $x { mapping($_, $x) }
>       ...
>

I am afraid I don't understand this one. ¿Which value is $_ suposed to get?


> The Perl5-ish:
>
>       @sorted_by_size =
>               map { $_->[0] }
>                       sort { $a->[1] <=> $b->[1] }
>                               map { [$_, -s] }
>                                       @files;
>
>would become:
>
>       @sorted_by_size =
>               map sort map @files
>                       { [$_, -s] }
>                               { $^a[1] <=> $^b[1] }
>                                       { $_[0] };
>
>Though I suppose the method call approach solves that nicely too:
>
>       @sorted_by_size =
>               @files.map( { $_[0] })
>                         .sort({ $^a[1] <=> $^b[1] })
>                         .map( { [$_, -s] });
>
>with the operations reading left-to-right, down the page.
>


Mmm.. If we did reverse the order of the arguments I was expecting it to
become:

        @sorted_by_size =
                @files.map({ [$_, -s] })
                        .sort({ $^a[1] <=> $^b[1] })
                        .map({ $_[0] })


Or if that was not decided, then I would expect:

        @sorted_by_size = { $_[0] }.map (
                { $^a[1] <=> $^b[1] }.order (
                        { $^a[1] <=> $^b[1] }.map (@files)
                )
        );


By the way, assuming the order of list manipulation operators was actually
reversed, ¿would the following be correct perl6?

        @sorted_by_size =
                @files.map  -> $file  { [$file, -s $file] }
                        .sort -> @a, @b { @a[1] <=> @b[1]   }
                        .map  -> @pair  { @pair[0]          }



--------------
Angel Faus
[EMAIL PROTECTED]

Reply via email to