Skip to content

Instantly share code, notes, and snippets.

@Lysxia
Created February 11, 2019 23:03
Show Gist options
  • Select an option

  • Save Lysxia/d64bbfc4f7acb25a315f5ca605dd2ddc to your computer and use it in GitHub Desktop.

Select an option

Save Lysxia/d64bbfc4f7acb25a315f5ca605dd2ddc to your computer and use it in GitHub Desktop.
infinite random list
import Test.QuickCheck
randomList :: Gen [Double]
randomList = do
start <- choose (0.7 :: Double, 1.2)
go start
where go prev = do
new <- choose (min 0.7 (prev-0.1), max (prev+0.1) 1.2)
acc <- go new
return (new : acc)
foo :: IO ()
foo = generate randomList >>= (print . take 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment