weighted.icn: Procedure to shuffle list with randomness

link weighted
May 23, 1994; Erik Eid
This file is in the public domain.

    WeightedShuffle returns the list "sample" with only a portion of the
elements switched.  Examples:

    L := WeightedShuffle (X, 100)   - returns a fully shuffled list
    L := WeightedShuffle (X, 50)    - every other element is eligible to
                                      be switched
    L := WeightedShuffle (X, 25)    - every fourth element is shuffled
    L := WeightedShuffle (X, 0)     - nothing is changed

    The procedure will fail if the given percentage is not between 0 and
100, inclusive, or if it is not a numeric value.

Source code | Program Library Page | Icon Home Page