Created
April 26, 2018 08:53
-
-
Save jc99kuo/05d0728b3b479465b0b1d62fa7c03aeb to your computer and use it in GitHub Desktop.
FLOLAC 2018 Week 1 (2018-4-25 14:14) -- nub: filter out duplicating integers on a list
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
| -- FLOLAC 2018 Week 1 -- nub: filter out duplicating integers on a list | |
| nub :: [Int] -> [Int] | |
| nub ix = dedup [] ix | |
| where | |
| dedup = \xs ys -> | |
| case ys of | |
| [] -> xs | |
| (yhead:ytail) -> | |
| if (elem yhead xs) then | |
| dedup xs ytail | |
| else | |
| dedup (xs ++ [yhead]) ytail |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment