[x,y,t,b,l,r] <- mapM (getStdRandom . randomR) [(-10,10), (-70,70), ...]
return (BoxBounds ...)

2009/10/4 Michael Mossey <[email protected]>:
> I'm looking for a hint to write the following code with less redundancy. I
> have a constructor called BoxBounds, and I want to make one with random
> values.
>
> randomBox :: IO BoxBounds
> randomBox = do
>  x <- getStdRandom (randomR (-10,10))
>  y <- getStdRandom (randomR (-70,70))
>  t <- getStdRandom (randomR (5,10))
>  b <- getStdRandom (randomR (5,10))
>  l <- getStdRandom (randomR (5,10))
>  r <- getStdRandom (randomR (5,10))
>  return (BoxBounds x y l r t b)
>
> _______________________________________________
> Haskell-Cafe mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Eugene Kirpichov
Web IR developer, market.yandex.ru
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to