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

Feature request: @.> #79

Open
ngphuoc opened this issue Jan 26, 2018 · 1 comment
Open

Feature request: @.> #79

ngphuoc opened this issue Jan 26, 2018 · 1 comment

Comments

@ngphuoc
Copy link

ngphuoc commented Jan 26, 2018

julia> 1:3 |> 
WARNING: sqrt(x::AbstractArray{T}) where T <: Number is deprecated, use sqrt.(x) instead.
Stacktrace:
...
 1.0
 1.41421
 1.73205

julia> 1:3 .|> 
3-element Array{Float64,1}:
 1.0
 1.41421
 1.73205

julia> @> 1:3 
WARNING: sqrt(x::AbstractArray{T}) where T <: Number is deprecated, use sqrt.(x) instead.
...
3-element Array{Float64,1}:
 1.0
 1.41421
 1.73205

julia> @.> 1:5 
ERROR: UndefVarError: @.> not defined
@ngphuoc
Copy link
Author

ngphuoc commented Jan 26, 2018

My version for @.> adapted from @>

macro .>(exs...)
  thread(x) = isexpr(x, :block) ? thread(rmlines(x).args...) : x

  thread(x, ex) =
    isexpr(ex, :call, :macrocall) ? Expr(Symbol("."), ex.args[1], Expr(:tuple, x, ex.args[2:end]...)) :
    isexpr(ex, :block)            ? thread(x, rmlines(ex).args...) :
    Expr(:call, ex, x)

  thread(x, exs...) = reduce(thread, x, exs)

  esc(thread(exs...))
end

I haven't figure out one for @.>> yet

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

No branches or pull requests

1 participant