> Can I suggest that an alternative solution might be the following: > > Suppose Perl 6 had two new very low precedence operators: ~> and <~ > (a.k.a. "bind rightwards" and "bind leftwards") > > @out = @a ~> grep {...} ~> map {...} ~> sort; > > @out = sort <~ map {...} <~ grep {...} <~ @a; > > That way, everything is still a method call, the ultra-low precedence of > <~ and ~> eliminate the need for parens, and (best of all) the > expressions actually *look* like processing sequences.
(a) OOh, shiny! (b) Can <~ and ~> be used at the same time? I'm not entirely sure of what functions take two array params meaningfully, but could we do: @a ~> grep (...) ~> sort ~> for <~ map (...) <~ @b { (for content goes here) } With the understanding that (1) EWWW, that is horribly ugly, but it was the first thing I could come up with that meaningfully takes two list args (2) Anyone who ACTUALLY does this with a for be shot on sight? It would be more meaningful in another function that takes two lists and does something useful, but without a body block ... More of a @a ~> grep (...) ~> apply <~ sort <~ @b ; So that the grep'd elements of @a are applied, 1:1, to the sorted @b ... ala apply (grep (..., @a), sort(@b)); (again, more useful for a longer chain) --attriel