Skip to content

Instantly share code, notes, and snippets.

@nobsun
Last active January 31, 2019 00:00
Show Gist options
  • Save nobsun/6108918 to your computer and use it in GitHub Desktop.
Save nobsun/6108918 to your computer and use it in GitHub Desktop.
遅延リストの間欠生成 ref: https://qiita.com/nobsun/items/850f48c8c8fbc2277816
module DelayList where
import Control.Concurrent (threadDelay)
import System.IO.Unsafe (unsafeInterleaveIO)
delayList :: Int -> [a] -> IO [a]
delayList _ [] = unsafeInterleaveIO $ return []
delayList i (x:xs)
= unsafeInterleaveIO $ threadDelay i >> delayList i xs >>= return . (x:)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment