标题对其进行了很好的总结。有没有一种简单的方法可以远程显示功能的帮助信息?
DispHelp = function(query_string)
# Enter help mode as you would by pressing `?` and query the given string
print(help_text)
return help_text
end
有什么想法吗?
答案 0 :(得分:3)
可能。
julia-1.2> for f in [sin, cos, tan]
println(Base.doc(f))
end
```
sin(x)
```
Compute sine of `x`, where `x` is in radians.
```
sin(A::AbstractMatrix)
```
Compute the matrix sine of a square matrix `A`.
If `A` is symmetric or Hermitian, its eigendecomposition ([`eigen`](@ref)) is used to compute the sine. Otherwise, the sine is determined by calling [`exp`](@ref).
# Examples
```jldoctest
julia> sin(fill(1.0, (2,2)))
2×2 Array{Float64,2}:
0.454649 0.454649
0.454649 0.454649
```
```
cos(x)
```
Compute cosine of `x`, where `x` is in radians.
```
cos(A::AbstractMatrix)
```
Compute the matrix cosine of a square matrix `A`.
If `A` is symmetric or Hermitian, its eigendecomposition ([`eigen`](@ref)) is used to compute the cosine. Otherwise, the cosine is determined by calling [`exp`](@ref).
# Examples
```jldoctest
julia> cos(fill(1.0, (2,2)))
2×2 Array{Float64,2}:
0.291927 -0.708073
-0.708073 0.291927
```
```
tan(x)
```
Compute tangent of `x`, where `x` is in radians.
```
tan(A::AbstractMatrix)
```
Compute the matrix tangent of a square matrix `A`.
If `A` is symmetric or Hermitian, its eigendecomposition ([`eigen`](@ref)) is used to compute the tangent. Otherwise, the tangent is determined by calling [`exp`](@ref).
# Examples
```jldoctest
julia> tan(fill(1.0, (2,2)))
2×2 Array{Float64,2}:
-1.09252 -1.09252
-1.09252 -1.09252
```
借助Julia,您可以阅读所有内容的代码,因此花几个小时浏览the source应该会启发您。
答案 1 :(得分:1)
完成播客关于如何显示内置功能帮助的答案。
如果要在自己的函数上显示帮助,则必须在此示例函数上编写如下的文档字符串:
#Here is my docstring between triple quote, just before function declaration
"""
square(x)
Return the square of x, if it's a number. If it's a vector, return element-wise square of the vector
"""
function square(x)
#And now the body of my function
out = x.*x
end