Skip to content

Instantly share code, notes, and snippets.

@horus
Created June 11, 2013 15:25
Show Gist options
  • Select an option

  • Save horus/5757797 to your computer and use it in GitHub Desktop.

Select an option

Save horus/5757797 to your computer and use it in GitHub Desktop.
import Control.Monad.State
half :: Int -> State [Int] Int
half x = do
xs <- get
put (x:xs)
return (x `div` 2)
main = print $ runState (half >=> half >=> half >=> half >=> half >=> half >=> half >=> half >=> half >=> half $ 1024) []
-- (1,[2,4,8,16,32,64,128,256,512,1024])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment