Ideas for extensions to math/rand?

163 views
Skip to first unread message

Joshua Liebow-Feeser

unread,
Aug 1, 2014, 2:36:25 AM8/1/14
to golan...@googlegroups.com

Hi All,

I'm writing a package that is intended to serve as an extension to math/rand, and I'm looking for ideas for what to include. So far the additions include:

  • Methods for all numerical types (uint8 through uint64, int8...int64, floats, and complexes)

  • Methods for random integers using the full range (that is, may generate negative numbers as well)

  • Methods for randomly generating strings (including length, which is distributed exponentially)

  • Methods for generating random instances of arbitrary types

Any ideas?


Cheers,

Josh

Harmen B

unread,
Aug 1, 2014, 5:05:15 AM8/1/14
to Joshua Liebow-Feeser, golang-nuts
Check out this message which got posted here a few hours ago:




--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joshua Liebow-Feeser

unread,
Aug 1, 2014, 3:58:45 PM8/1/14
to golan...@googlegroups.com, josh...@gmail.com
Oh that looks pretty cool.

I'm actually looking for stuff that's less about new randomness and more about adding convenience functionality (largely because most of the math for stuff like Mersenne Twisters and the like is above me). Stuff like randomly generating strings and randomly generating arbitrary type instances all just use existing randomness under the hood; the real contribution is not in the randomness, but in the way the randomness is used.

zephyr...@gmail.com

unread,
Aug 2, 2014, 3:13:13 AM8/2/14
to golan...@googlegroups.com, josh...@gmail.com
For most of those things, even math/rand is plenty. Generating different numeric types can be done with rand.Int63() and converting, or the complex() built-in in that case. Crazy provides easy access to (u)int64, or you can just xor two rand.Int63()s to get the full 64 bits. The random string case is interesting, however.

Joshua Liebow-Feeser

unread,
Aug 2, 2014, 4:33:27 AM8/2/14
to zephyr...@gmail.com, golan...@googlegroups.com
Yeah, a lot of the stuff I added is really just convenience stuff. The really meaningful additions are the string generation and arbitrary type instantiation.
Reply all
Reply to author
Forward
0 new messages