我试着得到:
(1,2),(3,4),(4,5) = 1,3,4
我的主旋律:
fun2 :: [(Int,Int)] -> [Int]
fun2 [] = []
fun2 ((a,b):ts) = **drop b**:fun2 ts --have problem here 发布于 2022-02-20 21:13:01
您可以使用map和
fun2 :: [(a, b)] -> [a]
fun2 = map fst或者使用模式匹配,就像您已经做的那样:
fun2 :: [(a, b)] -> [a]
fun2 [] = []
fun2 ((a, _):ts) = a : fun2 tshttps://stackoverflow.com/questions/71198839
复制相似问题