我正在尝试创建一个函数列表是oz,这个列表将被粘贴到另一个函数作为输入。有人能帮我吗?
发布于 2014-04-07 01:57:37
declare
fun{Op State FunctionList}
case FunctionList of H|T then {Op {H State} T}
[] nil then State
end
end
X={Op 1 [fun{$ S} S+4 end
fun{$ S} S*2 end
fun{$ S} S-3 end
fun{$ S} S*S end]}
{Browse X}在该示例中,函数Op执行带有参数中状态的函数列表。(1+4)*2)-3)^2=49
declare
fun{Power L U} %return a list of power function from ^L to ^U
if L>U then nil
else fun{$ X} {Pow X L} end | {Power L+1 U}
end
end
FList={Power 0 10}
{Browse {Map FList fun{$ Fun} {Fun 2} end}}在另一个示例中,函数Power generate a list of power function X²X³...然后,对于列表中的每个函数,都会应用另一个函数。最后一个函数将每个函数作为参数,并将其设为2作为参数...
https://stackoverflow.com/questions/22887234
复制相似问题