Module fisheryates

An implementation of the Fisher-Yates algorithm, which allows to access an array in a random or pseudo-random order.

Functions

run (data, min, max, random, action) Runs the Fisher-Yates algorithm on the given data.


Functions

run (data, min, max, random, action)
Runs the Fisher-Yates algorithm on the given data.

The given action method is invoked on each item, which means that the action method gets items in random order.

Parameters:

  • data The array on which to operate.
  • min The minimum index of the array (inclusive).
  • max The maximum index of the array (inclusive).
  • random The method that returns random numbers, assumed to accept two parameters, a minimum and maximum value. Can also be a table with an instance method like the one descriped above.
  • action The action to perform on each item. Assumed to accept two parameters, the item and the current index.
generated by LDoc 1.4.2