onyx-lang icon indicating copy to clipboard operation
onyx-lang copied to clipboard

Feature request: pipelining operator

Open stugol opened this issue 9 years ago • 3 comments

Like the pipe operator, but works on elements of collections. Accepts local free functions, proc objects and blocks. Also accepts methods of the items.

fn(value) -> value + 1
puts [1,2,3] |>> fn |>> fn  -- outputs [3,4,5]
puts [1,2,3] |>> .to_s      -- calls a method on each object, outputs ["1", "2", "3"]

Essentially sugar for map. But nice sugar.

We could also have ?> for select, !> for reject, and so on.

stugol avatar Feb 22 '16 00:02 stugol

These are very specific sugars for very specific narrow-use methods.

I went down the road of zillions of operators in Jytron, about two-three years ago, and finally concluded that they sometimes took more screen estate, while still making code less clear. Haskell fails in this regard to, as far as I am concerned.

It does give important food for thought in any event! Some ideas about more general construct for accomplishing above in a terse way starts bubbling in my head. I'll get back to this.

ozra avatar Feb 25 '16 16:02 ozra

Hm. I really like this sugar though :(

stugol avatar Feb 25 '16 18:02 stugol

This has parallels to #89 also.

ozra avatar Sep 30 '16 18:09 ozra