Does Julia have a statement that looks like a Haskell dollar sign?

The Haskell dollar sign is a wonderful feature that f $ g, for example, fis evaluated with results gas an argument. It might look brilliantly like this:

sin $ sqrt $ abs $ f 2

Which is equivalent

sin(sqrt(abs(f(2))))

The dollar sign is good for me because it is more readable. I noticed that Julia has |>some pipelines. It seems to do this f |> g, which means it gtakes the evaluated result fas an argument. From what I noticed, it seems that I could write the above expression like this

2 |> f |> abs |> sqrt |> sin

But I was wondering if there was any kind of statement so that I could do something like what I did in Haskell.

+4
2

$ ( xor) ;

f $ y = f(y)

( -) , , . , - .

f ← x = f(x)

( , Haskell-esque!), :

julia> sin ← π
1.2246467991473532e-16

julia> expsin ← π
1.0000000000000002

julia> expsin ← π
1.0000000000000002
+15

( 0.6). Compat.jl.

help?> ∘
"∘" can be typed by \circ<tab>

  f ∘ g

  Compose functions: i.e. (f ∘ g)(args...) means f(g(args...)). The ∘ symbol can be
  entered in the Julia REPL (and most editors, appropriately configured) by typing
  \circ<tab>. Example:

  julia> map(uppercase∘hex, 250:255)
  6-element Array{String,1}:
   "FA"
   "FB"
   "FC"
   "FD"
   "FE"
   "FF"

, - , :

julia> (sinsqrtabs ∘ f)(2)
0.9877659459927356
+15

Source: https://habr.com/ru/post/1667219/


All Articles