Reputation: 2042
I just see an example, which is checking if a list is nondescendant
nondec :: Ord a => [a] -> Bool
nondec xs = and (map leq (zip xs (tail xs)))
where leq (x, y) = x <= y
I'm wondering can I define more than one function under the where syntax.
For example, if the map function is undefined, can I define it as this
where leq (x, y) = x <= y
map(...)
Upvotes: 0
Views: 109
Reputation: 170713
can I define it as this
Why not try it? Because yes, you can do it exactly like this. leq
and map
just need to start in the same column and to the right of the column where the line with where
starts (not necessarily to the right of where
itself).
I think the Wikibook explains the rules for indentation quite well.
Upvotes: 3
Reputation: 11940
Indent, as usual:
nondec :: Ord a => [a] -> String
nondec as = map leq as where
leq = id
map _ _ = "Hi!"
Upvotes: 2