Last active
December 22, 2015 20:29
-
-
Save WillNess/6526878 to your computer and use it in GitHub Desktop.
This file contains 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
s = filter (`notElem`s) x -- NOT | |
s = foldr (\(n,a) r-> if (a `notElem` take n s) then a:r else r) [] $ zip [0..] x -- not quite, yet | |
s = let a = [ [e | e `notElem` take n s] | (n,e) <- zip c x] -- here it is! | |
b = map length a -- \ | |
c = scanl (+) 0 b -- \ | |
s = concat a -- _this_ `s` | |
in s | |
-- or, as a function, | |
filterNub xs = s | |
where | |
s = concat a | |
a = [ [e | e `notElem` take n s] | (n,e) <- zip c xs] | |
b = map length a | |
c = scanl (+) 0 b | |
-- which is | |
filterNub xs = s | |
where | |
s = concat . fix $ map (\(e,n)-> [e | e `notElem` take n s]) . zip xs . scanl ((.length).(+)) 0 | |
s = concat . fix $ zipWith (\e n-> [e | e `notElem` take n s]) xs . scanl ((.length).(+)) 0 | |
s = concatMap fst . fix $ (([],0):) . zipWith (\e (_,n)-> | |
let r=[e | e `notElem` take n s] in (r,n+length r)) xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment