Skip to content

Commit

Permalink
Improve P16
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhijit Sarkar committed Jan 4, 2024
1 parent 70422c6 commit b6fe568
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/Lists2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,7 @@ repli xs n = xs >>= replicate n

-- Problem 16: (**) Drop every N'th element from a list.
dropEvery :: [a] -> Int -> [a]
dropEvery xs n = concat $ go xs
where
go ys
| null right = [left]
| otherwise = left : go (tail right)
where
(left, right) = L.splitAt (n - 1) ys
dropEvery xs n = [x | (i, x) <- zip [1 ..] xs, i `mod` n /= 0]

{-
Problem 17: (*) Split a list into two parts;
Expand Down

0 comments on commit b6fe568

Please sign in to comment.