-
-
Couldn't load subscription status.
- Fork 81
Open
Description
This is hard to explain.
here is a demo
I want to remove the second argument of a 3 argument function.
julia> using MacroTools: textwalk
julia> code = """
test_scalar(cos, x -> -sin(x), x)
test_scalar(tan, x -> 1 + tan(x)^2, x)
test_scalar(sec, x -> sec(x) * tan(x), x)
test_scalar(csc, x -> -csc(x) * cot(x), x)
""";
julia> function twoarg(expr)
@capture(expr, t_(f_, d_, x_)) && t==:test_scalar && return :(test_scalar($(f), $x))
return expr
end
twoarg (generic function with 1 method)
julia> textwalk(twoarg, code) |> println
test_scalar(c, x)
test_scalar(t, x)
test_scalar(s, x)
test_scalar(c, x)
Metadata
Metadata
Assignees
Labels
No labels