我正在玩Elixir。只是想知道是否可以使用管道|>
运算符将参数传递给匿名函数。这是我的意思。如何使用管道运算符将参数传递给匿名函数?
a = [1,2,3] #=> [1,2,3]
m = fn ([h|t]) -> [ h*h | m.(t) ] end #=> head squared and call m with tail. Not sure how to use & shortcut for this.
m.(a) #=> [1,4,9]
a |> m #=> undefined function m/1 (understood. Arity is 1)
a |> m.(&1) #=> unhandled &1 outside of capture
'米= FN([H | T]) - > [H * H | m。(t)]'会出错 – coderVishal