【发布时间】:2019-03-18 18:52:47
【问题描述】:
我有一个三元组列表[(Int, Int, Int)]
我编写了以下辅助函数。
--This function is used to check if the first element is over 20
checkValue :: (Int, Int, Int) -> Bool
checkValue (x, _, _) = x > 20
--This function is used to set the 3-tuple to return (50, 50, 50)
setValue :: (Int, Int, Int) -> (Int, Int, Int)
setValue a = (50, 50, 50)
我的目标是遍历 3 元组列表并应用我的辅助函数。
对于列表中的每个项目
运行 checkValue。
如果 checkValue = true,则将 setValue 应用于当前元组。
- 继续
所以基本上如果我有这个[(0, 0, 0)(30,15,0)]
它会返回[(0, 0, 0)(50, 50, 50)]
有人能指出我正确的方向吗,我被困了一段时间。
【问题讨论】:
标签: haskell recursion functional-programming