Gabriella439 / Gabriella439/turtle
Implement something like `drop`
- Dominant language
- Haskell
- Stars
- 978
- Forks
- 94
- PR merge metrics
- No merged PRs in 30d
Description
This is a reminder to myself to implement a function I mentioned on Stack Overflow:
http://stackoverflow.com/questions/28421469/how-to-drop-lines-when-streaming-from-a-file-using-haskell-and-the-turtle-librar/28422201#28422201
Here is the implementation:
``` haskell
import Data.IORef
import Turtle
drop :: Int -> Shell a -> Shell a
drop n s = Shell (\(FoldM step begin done) -> do
ref <- newIORef 0
let step' x a = do
n' <- readIORef ref
writeIORef ref (n' + 1)
if n' < n then return x else step x a
foldIO s (FoldM step' begin done) )
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.