<$*IN> ==> process() ==> print;

This A06 example got me thinking.
Could non-variadic subrountines in a pipeline be useful?

A single arg sub or block could be a map without the "map":

  <$*IN> ==> &process ==> print; 
  # print map { process($_) } <$*IN>

  (1..6) ==> { $_++ } ==> say;

A two param sub might reduce (I just caught up on the thread)
but that wouldn't play nicely with infinite or lazy lists.
Since that seems to be the point of pipelines, it's probably
a bad idea.  It could produce a stream of the accumulated results:

  (1..6) ==> { $^a + $^b } ==> ...;
  # (3,6,10,15,21) or (1,3,6,10,15,21)

Alternatively, the list could be processed pairwise, 
with or without overlaps, producing:

  (1+2),(2+3),(3+4),(4+5),(5+6)  # overlapping
  (1+2),      (3+4),      (5+6)  # non-overlapping

Overlapping seems more useful and less likely to cause
problems with an odd length list.

I think I should just post this before I start on:
  (1..6) ==> { $^a ... $^b ... $^c }


 It is bad to carry even a good thing too far.  Even concerning things such as
 Buddhism,  Buddhist sermons, and moral lessons, talking too much will bring
 harm.  -- Hagakure                             http://bereft.net/hagakure/

Reply via email to