File utils/fisheryates.lua

Functions

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


Functions

fisheryates.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 one parameter, the item.

Valid XHTML 1.0!