我在与获取和在递归函数从列表中抛弃了第一值的问题,请删除。哈斯克尔:获取并从列表
下面是代码:
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