(This is probably the best section to make this proposal)
I recently asked a question about how often the |> operator is used.
Many people don’t use the pipe operator because of its limitations (having to write a lambda every time the function to the right of |> takes more than one argument, or having to rely on external macros).
I wish there were more powerful versions of the pipe operator in the Base library that didn’t force you to write lambdas.
I’ve been thinking about something like this but I don’t know if they are good or bad practice:
a = [1:100;] a |> x -> reshape(x, 10, 10) |> # reshape to 10x10 matrix x -> my_function(x, args) |> # apply a function with other args to the matrix x -> reshape(x, size(a)) |> # convert to original size x -> filter(iseven, a)
|>₁(a, f_args::Tuple) = f_args(a, f_args[2:end]...) |>₂(a, f_args::Tuple) = f_args(f_args, a, f_args[3:end]...) |>₃(a, f_args::Tuple) = f_args(f_args, f_args, a, f_args[4:end]...) a = [1:100;] a |>₁ (reshape, 10, 10) |>₁ (my_function, args) |>₁ (reshape, size(a)) |>₂ (filter, iseven)
What are your thoughts on this? Does it make sense? Are there better ways to do this? Thank you.