I've just got aware of chaining functions (like a pipeline) in Julia for a couple of days. I was trying something today and got an unexpected result. Hence, I decided to ask about the root of the problem better to understand the behavior of Julia in chaining functions. Consider this example:
julia> a = [1 2 3]
1×3 Matrix{Int64}:
1 2 3
Then I want to chain some functions like the below, and after all, I want the maximum value of the entire Matrix:
julia> a .|> x->x^2 .|> sqrt .|> Int64 |> maximum
1×3 Matrix{Int64}:
1 2 3
But I expected just a 3
! Why doesn't Julia consider that last function of the chain, namely, the maximum
function?
PS: Also, I tried this way:
julia> a .|> x->x^2 .|> sqrt .|> Int64 |> x->maximum(x)
1×3 Matrix{Int64}:
1 2 3
Still not what I expected it to be.
:(a .|> x->x^2 .|> sqrt .|> Int64 |> maximum)
to the answer would make it clear how this expression is parsed by Julia. Thank you! – Detain