[Melbourne-pm] I <3 map & grep too :)

Brad Bowman list at bereft.net
Thu Oct 27 15:12:45 PDT 2011


On 27/10/11 17:22, Toby Corkindale wrote:
> On 27/10/11 17:12, Sam Watkins wrote:
[..]
>> I usually read map/grep chains in perl from the bottom up,
>> maybe because I'm accustomed to the shell's way of doing it.
[...]
>> An advantage of map / grep / reduce, compared to 'for', is that a program like
>> this could be run in parallel, in two different ways. It could operate on
>> multiple data in parallel (shell doesn't normally do that), and it could use
>> 'pipelining' with all the steps running in parallel (shell does do that).
>
>
> And indeed, I picked up this style of programming from Scala, which does do
> those operations in parallel - in both senses.
> It can start running the later operations before the early ones have finished
> - and it can use multiple CPUs to process each stage in parallel.
>
> It's pretty nifty, and I hope Perl gets functionality like that one day too..

Perl 6 has feed operators:

http://perlcabal.org/syn/S03.html#Feed_operators

I think they're lazy/pull-based like unix pipes, but
don't auto-thread (that's hyperops).

One nice novelty is that there are two options: <== and ==>.
<== reads bottom to top like the Perl 5 example, but
==> allows the chain to be written the other way (like unix).

It appears there are parallel variants: <<== and ==>>
(I can't be sure from s03 though)

Brad


More information about the Melbourne-pm mailing list