Skip to content

Instantly share code, notes, and snippets.

@DaveCTurner
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DaveCTurner/1f9c6742fb9acf024532 to your computer and use it in GitHub Desktop.
Save DaveCTurner/1f9c6742fb9acf024532 to your computer and use it in GitHub Desktop.
{-# LANGUAGE TupleSections #-}
import System.Random
import Control.Monad
import Data.List
import Text.Printf
main :: IO ()
main = do
let target = 4.7
let scaleSum xs = map ((* target) . (/ total)) xs where total = sum xs
xs <- fmap (scaleSum . map (10**)) (replicateM 20 (randomRIO (1.0, 3.0 :: Double)))
mapM_ (putStrLn . printf "%0.8f") xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment