Randomize a List problem
|
09-15-2020, 08:56 PM
Post: #15
|
|||
|
|||
RE: Randomize a List problem
(09-15-2020 06:39 PM)ijabbott Wrote: Those two are the classic Fisher-Yates shuffle algorithm, with the ROLL and ROLLD exchanging two items at specified stack positions. Is there a more efficient way to swap stack elements? In UserRPL I can't think of a faster way. Stack operations are generally faster than list operations. There are two ListExt commands that are germane to the current discussion: LSHUF implements the modern Fisher-Yates algorithm and is many times faster than any user implementation. DOPERM lists all permutations of a list taken n items at a time (see documentation). For instance, Albert's example of the 100th permutation of { 1 2 3 4 5 } would be { 1 2 3 4 5 } 5 << >> DOPERM 100 GET |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)