Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
{-# 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