[Haskell-cafe] better way to do this?

Felipe Lessa felipe.lessa at gmail.com
Sun Oct 4 07:27:04 EDT 2009


On Sun, Oct 04, 2009 at 01:55:11PM +0400, Eugene Kirpichov wrote:
> [x,y,t,b,l,r] <- mapM (getStdRandom . randomR) [(-10,10), (-70,70), ...]
> return (BoxBounds ...)

import Control.Applicative

let f = getStdRandom . randomR
    g1 = \x -> f (-x,x)
    g2 = f (5,10)
in BoxBounds <$> g1 10 <*> g1 70 <*> g2 <*> g2 <*> g2 <*> g2

--
Felipe.


More information about the Haskell-Cafe mailing list