-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: if no __
is specified then insert into first argument
#17
Comments
I think being explicit is a virtue of this package. Automatically inserting
(Note that |
Interesting argument. But |
Ah right, there's a way... and I guess Do you have examples of where you'd want first rather than last-argument |
The way that Lazy.jl deals with it is that
Also
without needing |
Overall I think this is an interesting idea, and might resolve some of the uglyness of
Thus, we'd have the following work: @_ data |> filter(abs(_)>1) |> map(_+1) |> scatter If there's no piping present, no The need to explicitly use Another option could be to... just add more underscores, and have a macro It's worth keeping in mind that this package is not just about pipelines, though that's one of the nice use cases for it (I think where you mention
Personally I don't like the implicit chaining syntax in Lazy.jl at all so I'd rather not emulate it! |
Yeah, transducers are always "curried". So, we'd need extra |
@xiaodaigh I still think this is a good idea; we'd just need to modify it a little. What if we implemented a |
A bit crazy idea is to use some infix combinator like julia> f $ args::Tuple = x -> f(args..., x)
f $ a = x -> f(a, x)
$ (generic function with 2 methods)
julia> @_ -3:3 |> filter$(abs(_)>1) |> map$(_+1) |> collect
4-element Array{Int64,1}:
-2
-1
3
4 Though it's not ideal that |
I've found a couple of uses of @_ read(`git status --porcelain`) |> String |> split(__,'\n') |
_
is specified then insert into first argument__
is specified then insert into first argument
Currently
@_ a |> f(_, b)
is needed but in other tools like Lazy.jl and R's magrittr which allows the first argument to be the previous one without_
e.g.@_ a |> f(b)
would be equivalent tof(a,b)
and@_ a |> f(_, b)
The text was updated successfully, but these errors were encountered: