
27 Jan
2021
27 Jan
'21
1:01 a.m.
I'm looking at this https://wiki.haskell.org/99_questions/Solutions/8 and wondering how the "as pattern" actually is working compress (x:ys@(y:_)) | x == y = compress ys | otherwise = x : compress ys compress ys = ys I'm sure it's just some version of my stab at eliminating consecutive duplicates in a list compress :: Eq a => [a] -> [a] compress [] = [] compress [x] = [x] compress (x:y:xs) = if x == y then compress (y:xs) else x : compress (y:xs) only smarter. Could someone walk me through the (x:ys@(y:_)) part? LB