Reputation: 33
I have defined the following functions:
isOk :: Group -> Bool
//some condition
filterGroup :: [Group] -> [Group]
filterGroup g = filter isOk g
getGroupNb :: Group -> NoGroupe
getGroupNb (Group _ noGroupe _ _ _) = noGroupe
nbGroup :: [Group] -> [NoGroupe]
nbGroup groupX = map getGroupNb groupX
I want to apply the function filterGroup
to the [Group]
that is passed as a parameter to the last function nbGroup
. I would like something like that, for the last function:
nbGroup :: [Group] -> [NoGroupe]
nbGroup where [Group] = filterGroup[Group]
nbGroup groupX = map getGroupNb groupX
How can I apply a function to a parameter of another function?
Upvotes: 0
Views: 137
Reputation: 402
You could just apply the filter directly:
nbGroup :: [Group] -> [NoGroupe]
nbGroup groupX = map getGroupNb (filterGroup groupX)
Upvotes: 2