More on randoms.
Haskell uses the names `next', `split' for Random.
Maybe, it is better to add some prefix or suffix?
For there are so many basic operations in the universe that can be
naturally called `next' and `split'. And Random does not look so
priveleged to enjoy privately such a simple names.
Second.
Jerzy Karczmarczuk <[EMAIL PROTECTED]>,
Marc van Dongen <[EMAIL PROTECTED]> wrote
K: the Haskell standard libraries offer only the basic integer RNG,
K: which will force all the users to reconstruct the needed reals,
K: this is not extremely painful, but anyway.
K: I would love having 'next' returning reals as well...
K: And vectors (with decently uncorrelated elements). Etc.
D> Yes please. But do change the word vector into [Integer].
Maybe I am missing something, but why people need `next',
is not randomR enough?
Let for example, one needs a random vector. Define
instance (Random a) => Random (Vector a)
where
-- put a random vector "between vl and vh" to have random
-- components "between" l(i) and h(i) for each i
--
randomR (Vec lows, Vec highs) g = (Vec $ reverse xs, g')
where
(xs,g') = foldl rnd ([],g) $ zip lows highs
rnd (xs,g) (l,h) = (x:xs,g') where (x,g') = randomR (l,h) g
What is wrong here?
As to Real, probably, there exists the standard randomR for it?
------------------
Sergey Mechveliani
[EMAIL PROTECTED]