leah blogs

August 2004

07aug2004 · rand.rb

rand.rb is a library for picking random elements and shuffling.

Overview

rand.rb adds new methods to Enumerable, Array, and Hash to:

  • return a random element (pick, pick_index, pick_key, pick_value and their destructive versions suffixed with !).

  • arrange elements in new, random order (shuffle, shuffle_hash_pairs, shuffle_hash).

  • use above methods in convenient ways (each_random, map_random).

It also provides these new facilities to String:

  • shuffle_chars, to arrange the characters of the string in new order.

  • pick_byte, pick_char and pick_index, to return random bytes, characters or elements.

History

  • November 26, 2004: Initial version done as IRC collaboration project between kig and chris2.

  • November 29, 2004: First release 0.9.

  • December 15, 2004: 0.9 officially announced.

Getting it

You can download rand.rb at
http://chneukirchen.org/releases/rand-0.9.0.tar.gz.

Upstream source

You can get latest development releases using darcs by executing:

darcs get http://chneukirchen.org/repos/rand

darcs send is the preferred way to send patches, but mailing diffs is fine too.

Authors

Please mail bugs, feature requests or patches to the mail addresses above or use IRC to contact the developers.

Copyright

Copyright © 2004 Ilmari Heikkinen
Parts Copyright © 2004 Christian Neukirchen
This work is licensed under the same terms as Ruby itself.

Copyright © 2004–2022