0
defmodule Maps do
def map([],[]) do [] end
def map([x|xs], [x1 | xs1])
do map([xs],[xs1]) ++ [(x + x1) | []] end
end
我不明白它的問題。假設您運行Maps.map([1],[2])
。然後它應該做map(xs,xs1)
和xs = []
和xs1 = []
是空的,map ([],[])
應該返回[]
,它結束遞歸。然後 [] ++ [1+2] = [3]
所以結果應該返回[3]
。但是,這隻會凍結我的終端。該模塊保持超時?
Thanks that wor KS –