3 ms·
The author suggests that Haskell could benefit from rewriting nodups = dedup [] where dedup m [] = m dedup m (x:xs) = dedup (if x `elem` m then
by tromp 5y ago
The author suggests that Haskell could benefit from rewriting
nodups = dedup [] where
dedup m [] = m
dedup m (x:xs) = dedup (if x `elem` m then m else m++[x]) xs
as some syntactic sugar while loop:
nodups l = while k != []
k = l ||| tail l
m = [] ||| if head k `elem` m then m else m ++ head k
result = m
but I would disagree. Btw, the former appears to suffer from quadratic slowdown due to repeated use of ++ which can be avoided by replacing m++[x] with x:m and making dedup m [] = reverse m.