小编jam*_*mie的帖子

如何返回元组列表的最低值元组?

我有一个带有名称和浮点数的元组列表。如何返回具有最低浮点值的元组?

例子

[("bob",23),("Alice",32),("Susan",1)]

rtnLowestDist :: [(Name, Float)] -> (Name, Float)
Run Code Online (Sandbox Code Playgroud)

返回 ("Susan",1)

haskell

0
推荐指数
1
解决办法
70
查看次数

Haskell 一直给我输入错误

不知道我做错了什么

type Name = String
type Location = (Float,Float)
type RainfallFigures = [Int]
type Place = (Name,Location,RainfallFigures)

rtnClosestDryPlace :: (Location -> Int -> [Place] -> [(Name,Float)]) -> (Name,Float)
rtnClosestDryPlace p1 n ((a,p2,c):xs) = rtnLowestDistance (distanceList p1 (rtnFullDryPlaces ((a,p2,c):xs) n))

    Couldn't match expected type ‘(Name, Float)’
                      with actual type ‘Int
                    -> [(Name, Location, RainfallFigures)] -> (Name, Float)’
        • The equation(s) for ‘rtnClosestDryPlace’ have three arguments,
          but its type ‘(Location -> Int -> [Place] -> [(Name, Float)])
                        -> (Name, Float)’
          has only …
Run Code Online (Sandbox Code Playgroud)

haskell

0
推荐指数
1
解决办法
67
查看次数

标签 统计

haskell ×2