Last active
December 15, 2015 09:09
-
-
Save CaglarGonul/5236720 to your computer and use it in GitHub Desktop.
A simple ML algorithm for removing duplicates in a list is given below :
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 remove_duplicates (xs) = | |
case xs of | |
[]=>[] | |
| x::xs' => if List.exists (fn y=> x=y) xs' | |
then remove_duplicates (xs') | |
else x::remove_duplicates (xs') | |
val test_remove_duplicates = remove_duplicates ([3,3,3,3,5,5,5,5,6,6,6,6,7]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment