LoginSignup
8
3

More than 5 years have passed since last update.

Elm pipe vs Elixir pipe

Last updated at Posted at 2018-03-13

 へぇー、ElixirってElmと同じpipeオペレータ( |> )が使えるんだ。便利だねー、って思っていたら、よく見ると違う。まるっきり違うのならともかく、表記法も同じで使い方もほぼ同じ、ちょっとだけ違うっていうのは勘違いしがちなので、心に刻んでおくためのメモです。

 Elmの場合、6 |> f 3 は f(3,6) と解釈されます。curryが考慮されている?

elm
$ elm-repl
> f a b = a / b
<function> : Float -> Float -> Float
> 6 |> f 3
0.5 : Float

 Elixirの場合、6 |> f.(3) は f(6,3) と解釈されます。

elixir
$iex
iex(1)> f = fn x, y -> x / y end
#Function<12.99386804/2 in :erl_eval.expr/5>
iex(2)> 6 |> f.(3)
2.0

 以上

8
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
3