Skip to content

Instantly share code, notes, and snippets.

@chomado
Created June 20, 2013 04:13
Show Gist options
  • Save chomado/5820263 to your computer and use it in GitHub Desktop.
Save chomado/5820263 to your computer and use it in GitHub Desktop.
mynub :: Eq a => [a] -> [a]
mynub [] = []
mynub (x : xs) = x : mynub (filter (\y -> x /= y) xs)
-- nub :: Eq a => [a] -> [a]
-- Input: nub [0,1,2,3,2,1,0] 重複するものを取り除く
-- Output: [0,1,2,3]
-- filter (>3) [3, 5, 9, 10, 3, 1, 0, 3, 5]
-- [5,9,10,5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment