Skip to content
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

Broadcasted piping .|> #20

Closed
mcabbott opened this issue Sep 29, 2020 · 2 comments · Fixed by #21
Closed

Broadcasted piping .|> #20

mcabbott opened this issue Sep 29, 2020 · 2 comments · Fixed by #21

Comments

@mcabbott
Copy link
Collaborator

Seems like this ought to work:

julia> @_ 1:4 .|> float |> filter(iseven(Int(_)), __) .|> sqrt              
#27 (generic function with 1 method)

julia> 1:4 .|> float |> xs -> filter(x -> iseven(Int(x)), xs) .|> sqrt 
2-element Array{Float64,1}:
 1.4142135623730951
 2.0

See also https://discourse.julialang.org/t/in-pipe-pipe-followed-by-gives-an-error/47174 for other examples.

@mcabbott
Copy link
Collaborator Author

Fix also allows this, in which __ now sometimes means an element, I think that's OK:

julia> @_ 2 |>  __ .+ (1:3)  .|>  __^2 |> filter(isodd(_), __)
2-element Array{Int64,1}:
  9
 25

@c42f
Copy link
Owner

c42f commented Nov 5, 2020

__ now sometimes means an element

I guess this should work, odd as it is!

@c42f c42f closed this as completed in #21 Nov 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants