Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List 如何显示没有特定项的列表。_List_Haskell - Fatal编程技术网

List 如何显示没有特定项的列表。

List 如何显示没有特定项的列表。,list,haskell,List,Haskell,我有以下列表,其中包含字符串列表。。 我已经在原始列表中搜索了包含字符串“tom”的列表,并得到了以下列表 [["leo", "tom"], ["meg", "tom"], ["George", "john", "adam", "tom"] ] 我现在希望显示这个列表而不显示“tom”,我会通过列表理解来完成,但我不知道如何对包含列表的列表执行此操作?有人能帮我找到正确的方向吗 我认为,将此作为一个列表来写会变得复杂。更容易链接简单的函数 -- Intended as l `without`

我有以下列表,其中包含字符串列表。。 我已经在原始列表中搜索了包含字符串“tom”的列表,并得到了以下列表

[["leo", "tom"], ["meg", "tom"], ["George", "john", "adam", "tom"] ]

我现在希望显示这个列表而不显示“tom”,我会通过列表理解来完成,但我不知道如何对包含列表的列表执行此操作?有人能帮我找到正确的方向吗

我认为,将此作为一个列表来写会变得复杂。更容易链接简单的函数

-- Intended as l `without` x
without :: Eq a => [a] -> a -> [a]
without l x = filter (/= x) l

containing :: Eq a => [[a]] -> a -> [[a]]
containing l x = filter (x `elem`) l

listsWithTom = lists `containing` "tom"
listsMinusTom = map (`without` "tom") listsWithTom
或者在你的特殊情况下

notom = map init

好的,我有一个创建原始列表的函数名,我是否将它们放在“无”和“包含”部分?只需用您的输入替换
列表即可。好的,这就是我一直在寻找的,但是如果我已经有一个函数,我如何将其添加到函数中?@Dave5678,
notomFun=notom。乐趣
notom = map (filter (/= "tom"))
notom = map init