random numbers

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

random numbers

Ian Martins
the api has four ways to get random numbers:

Math.Random : Float
Std.random(x:Int) : Int
neko.Random.float() : Float
neko.Random.int(max:Int) : Int

is neko.Random needed?
can Std.random(x) be moved into the Math class?
is it possible to set the seed if you're not using neko?

-Ian


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: random numbers

Robert Sköld
I think it would be nice to have something like Grant Skinners seeded  
(although i'd think the seed could be optional) random (http://www.gskinner.com/blog/archives/2008/01/source_code_see.html 
) in the cross target haxe package. I like the API of it...

And then i guess the Math.random() would be the platform native  
"random".

Just my 2 cents :)

/bob

On Apr 30, 2009, at 01:19, Ian Martins wrote:

> the api has four ways to get random numbers:
>
> Math.Random : Float
> Std.random(x:Int) : Int
> neko.Random.float() : Float
> neko.Random.int(max:Int) : Int
>
> is neko.Random needed? can Std.random(x) be moved into the Math  
> class? is it possible to set the seed if you're not using neko?
>
> -Ian
>
>
> --
> haXe - an open source web programming language
> http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: random numbers

Nicolas Cannasse
In reply to this post by Ian Martins
Ian Martins a écrit :
> the api has four ways to get random numbers:
>
> Math.Random : Float
> Std.random(x:Int) : Int
> neko.Random.float() : Float
> neko.Random.int(max:Int) : Int
>
> is neko.Random needed? can Std.random(x) be moved into the Math class?
> is it possible to set the seed if you're not using neko?

Well, having Std.random() and Math.random() is just an old habit which
also matches the ECMA apis (the global random() function is in Std and
there is also Math.random())

Std.random is implemented in neko with neko.Random, so it's made
accessible as well.

I'm not sure there is something to remove here.

Nicolas

--
haXe - an open source web programming language
http://haxe.org