Last active
August 29, 2015 14:26
-
-
Save DaveCTurner/1f9c6742fb9acf024532 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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