【发布时间】:2023-04-02 17:36:01
【问题描述】:
当试图定义一个函数时,该函数将从集合 a 中删除集合 m 的最大子集,该子集也是集合 a 的子集,我遇到了以下错误:
filename.hs:7:33:parse error (possibly incorrect indentation)
以下代码:
exclude :: Integral t => [t] -> [t] -> [t]
a `exclude` m
| m == [] = a
| a == (b ++ c) = b
| otherwise = []
where b /= []
where c = [z | z <- m]
如何实现多个条件/定义(使用 where 或其他方式),或更正函数以以不同方式正常工作?
【问题讨论】:
-
where b /= []的意图是什么? -
预期结果是
a中不是m元素的那些元素的列表吗? -
预期结果确实是 a 的所有元素都不是 m 的元素。顺便说一句,感谢丹尼尔对语法的帮助,即使它没有解决问题。
-
a 'exclude' m = filter (
notElemm) a 有效。谢谢 joachifm/Christian
标签: list haskell set where-clause