Created
December 16, 2012 20:38
-
-
Save edwinb/4312639 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Not fine: | |
mergeBy : (a -> a -> Ordering) -> List a -> List a -> List a | |
mergeBy order [] right = right | |
mergeBy order left [] = left | |
mergeBy order (x::xs) (y::ys) = | |
case order x y of | |
LT => x :: mergeBy order xs (y :: ys) | |
_ => y :: mergeBy order (x :: xs) ys | |
-- Fine: | |
mergeBy : (a -> a -> Ordering) -> List a -> List a -> List a | |
mergeBy order [] right = right | |
mergeBy order left [] = left | |
mergeBy order (x::xs) (y::ys) = | |
let rx = x::xs in | |
let ry = y::ys in | |
case order x y of | |
LT => x :: mergeBy order xs ry | |
_ => y :: mergeBy order rx ys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment