我有一个带有名称和浮点数的元组列表。如何返回具有最低浮点值的元组?
例子
[("bob",23),("Alice",32),("Susan",1)]
rtnLowestDist :: [(Name, Float)] -> (Name, Float)
Run Code Online (Sandbox Code Playgroud)
返回 ("Susan",1)
不知道我做错了什么
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 ×2