Skip to content

Instantly share code, notes, and snippets.

@CaglarGonul
Last active December 15, 2015 09:09
Show Gist options
  • Save CaglarGonul/5236720 to your computer and use it in GitHub Desktop.
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 :
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