Method chaining with arguments to imitate unix piping?

dear julia experts: I am trying to understand method chaining. I believe that instead of f(g(x)), this means I can use g(x) |> f().

Can one do more than this? Say, I have defined

julia> grep(heystack,needle) = filter( x->contains(x, needle), heystack )
grep (generic function with 1 method)

is it possible to accomplish something like readdir("/etc") |> grep("password"), akin to Unix piping, in Julia now? I suspect not, but was wondering…

regards, /iaw

Nope, this means that you can use g(x) |> f, ie you use f as a function.

You can of course do that, but you have to make the second argument of |> a closure, eg s -> ismatch(regex, s).

1 Like

See https://github.com/MikeInnes/Lazy.jl/blob/master/README.md#macros
for chaining with arguments

1 Like