Created
April 6, 2021 20:14
-
-
Save snoble/b8cb38a88a52338f59ba43b12af5dda9 to your computer and use it in GitHub Desktop.
An add operation that appears to be a semilatice
This file contains hidden or 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
addLists : (a -> a -> Order) -> List a -> List a -> List a | |
addLists compareFn lst1 lst2 = | |
case ( lst1, lst2 ) of | |
( _, [] ) -> | |
lst1 | |
( [], _ ) -> | |
lst2 | |
( h1 :: t1, h2 :: t2 ) -> | |
case compareFn h1 h2 of | |
EQ -> | |
h1 :: addLists compareFn t1 t2 | |
GT -> | |
h1 :: addLists compareFn t1 lst2 | |
LT -> | |
h2 :: addLists compareFn lst1 t2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment