【发布时间】:2016-05-29 15:52:15
【问题描述】:
我写了以下简单的模型:
defmodule Simple do
def add(a, b) do a + b end
som = fn(x, y) -> x + y end
def oper_array(fct, arr, init) do
Enum.scan(arr, init, fct.())
end
end
但是
Simple.oper_array(a, 0, Simple.som) or
Simple.oper_array(a, 0, Simple.add)
永远给予
(UndefinedFunctionError) undefined function Simple.som/0 or
(UndefinedFunctionError) undefined function Simple.add/0
如果我这样写函数 'oper_array' 会得到同样的结果:
Enum.scan(arr, init, fct)
我应该如何编写函数'oper_array'?
【问题讨论】:
标签: elixir