Last active
August 29, 2015 14:01
-
-
Save drostron/a97e659abde1635461a0 to your computer and use it in GitHub Desktop.
list value homogeneity
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
| let rec i j = match j with | |
| | [] | [_] -> true | |
| | a :: b :: c -> a = b && i(b::c);; |
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
| fun i [] = true | |
| | i [_] = true | |
| | i (a::b::c) = a = b andalso i(b::c); |
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
| let i :: (Eq j) => [j] -> Bool | |
| i [] = True | |
| i [_] = True | |
| i (a:b:c) = a == b && i(b:c) |
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
| total | |
| i : Eq a => List a -> Bool | |
| i [] = True | |
| i (_::[]) = True | |
| i (a::b::c) = a == b && i(b::c) |
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
| @tailrec | |
| def i[T](j: List[T]): Boolean = j match { | |
| case Nil | _ :: Nil ⇒ true | |
| case a :: b :: c ⇒ a == b && i(b::c) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment