[英]Filtering a list of lists in Haskell
I want a function Int -> [[String]]
, trying to filter out the elements that have a specific value on the Inth spot. 我想要一个函数
Int -> [[String]]
,试图过滤掉Inth点上具有特定值的元素。 I thought I could combine filter
and !!
我以为我可以结合
filter
和!!
but I can't get it to work. 但我无法正常工作。 So far I have:
到目前为止,我有:
filter (!! (== value)) rows
where value
is a String
and rows
is a [[String]]
. 其中
value
是一个String
而rows
是一个[[String]]
。 I thought it would take the Int
combined with a [String]
from rows
and check if that particular entry equals value
and then keep those rows, but it gets interpreted differently. 我认为应该将
Int
与rows
的[String]
组合起来,并检查该特定条目是否等于value
,然后保留这些行,但是对它的解释有所不同。 Any help would be appreciated. 任何帮助,将不胜感激。
(!! (== value))
is invalid because the right operand of !!
(!! (== value))
无效,因为!!
的正确操作数 must be an Int
. 必须是一个
Int
。 (== value)
is a function. (== value)
是一个函数。
Your options are 您的选择是
\n -> filter (\xs -> xs !! n == value) rows
or without the explicit lambda 或没有明确的lambda
\n -> filter ((== value) . (!! n)) rows
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.