a += 1 相当于 a = a + 1
我想拥有a |>= \xe2\x88\x9a或a |= \xe2\x88\x9a相当于a = a |> \xe2\x88\x9a.我可以定义这些新的运算符吗?
是否可以访问julia中另一个函数中定义的函数?例如:
julia> function f(x)
function g(x)
x^2
end
x * g(x)
end
f (generic function with 1 method)
julia> f(2)
8
julia> f.g(2)
ERROR: type #f has no field g
in eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:64
in macro expansion at ./REPL.jl:95 [inlined]
in (::Base.REPL.##3#4{Base.REPL.REPLBackend})() at ./event.jl:68
Run Code Online (Sandbox Code Playgroud) 有没有办法在运行时获取函数的签名?我想在调用该函数之前检查签名。就像是:
\n\nexp = @sig func\nif "kw" \xe2\x88\x88 string(exp)\n func(kw=value)\nend\nRun Code Online (Sandbox Code Playgroud)\n 我想检查变量是否是julia中的标量,例如Integer,String,Number,但不是AstractArray,Tuple,type,struct等.是否有一个简单的方法来执行此操作(即isscalar(x))
我想为宏创建一个别名。我当前的实现是创建一个新的宏来调用并传递参数,例如:
macro print(xs...)
quote
@show $(xs...)
end
end
Run Code Online (Sandbox Code Playgroud)
有没有更好的/内置的方法?