
25 Sep
2008
25 Sep
'08
4:26 p.m.
And the one liner: (rand 1 10) >>= return . (\v -> take v [1..10])
What about: take <$> rand 1 10 <*> pure [1..10] (more readable IMHO). One could even define: f <%> x = f <*> pure x and have take <$> rand 1 10 <%> [1..10] Also, why not using getRandomR(1,10) instead? take <$> getRandomR (1,10) <%> [1..10] :: (MonadRandom m) => m Int That way you separate the generation from the IO. My getRandomR(0,3) <%> cents. -- Ariel J. Birnbaum