Skip to content

Instantly share code, notes, and snippets.

@WillNess
Last active December 22, 2015 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WillNess/6526878 to your computer and use it in GitHub Desktop.
Save WillNess/6526878 to your computer and use it in GitHub Desktop.
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