我在與獲取和在遞歸函數從列表中拋棄了第一值的問題,請刪除。哈斯克爾:獲取並從列表
下面是代碼:
removeDuplicates a u = [if a == [] then u else removeDuplicates newA newU
| let newU = (head a):u
| let newA = tail a]
和錯誤:
Illegal parallel list comprehension: use -XParallelListComp
而另一個想法:
removeDuplicates a u = [if a == [] then u else removeDuplicates (tail a) newU
| let newU = (head a):u]
而另一個錯誤:
Occurs check: cannot construct the infinite type: a0 = [a0]
Expected type: [a0]
Actual type: [[a0]]
In the return type of a call of `removeDuplicates'
In the expression: removeDuplicates (tail a) newU
提前致謝。
編輯:此時,只有我想用這個功能做的事情是從第一個列表由一個移動的所有項目到第二遞歸函數之一。之後,我會添加更多的東西來從列表中刪除重複值。
你能更清楚它是什麼你想要做什麼? – Apocalisp
你想使用列表解析還是讓..在子句中?要通過一個移動的元素之一,@Apocalisp的代碼做這項工作 – nponeccop
的'ParallelListComp'是通過使用'造成[... | ... | ...]'。除非你喜歡做某事,否則總是'[... | ...]'。 – 2011-11-04 21:18:43