版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/mifangdebaise/article/details/85088570
Julia
中 |>
运算符如何使用,首先看下解释:
help?> |>
search: |>
|>(x, f)
Applies a function to the preceding argument. This allows for easy function
chaining.
Examples
≡≡≡≡≡≡≡≡≡≡
julia> [1:5;] |> x->x.^2 |> sum |> inv
0.01818181818181818
举个例子:
比如我定义了
func1(x)
,Julia
中有没有一个函数(假设为successfullyCall()
),只要我的函数func1
调用成功了,那么successfullyCall( func1(x) )
就返true
呢?
最终可以这么做:func1(x) |> x->true
julia> function func1(x)
x = (1.2, 3)
y = [1, 6]
return x, y
end
func1 (generic function with 1 method)
julia> func1(9) |> x->true
true