up previous next
RandomTuple

random tuple

Syntax
RandomTuple(L: LIST, K: INT): LIST

Description
The function returns a random tuple of L of cardinality K . This function can be quite useful for testing properties on some tuples of a large list when testing on all of them would be unfeasible in time and memory (see also tuples ).

Example
/**/ RandomTuple(["a","b","c","d","e","f","g","h"], 5);
["b", "b", "h", "g", "e"]

/**/ indent([RandomTuple(-9..9, 10) | i in 1..4]);
[
  [-5, -3, 1, 8, -4, 6, -5, -7, -1, 1],
  [-5, -8, 0, -9, -2, -1, 3, -6, 6, -3],
  [-2, -2, -9, -5, 0, -6, 2, -6, -5, -8],
  [-2, -4, 4, 3, -3, 5, 3, -1, 8, -7]
]

See Also