[ library(tentative) | Reference Manual | Alphabetic Index ]

random_sample(+Values, +SampleSize, -X)

Nondeterministically pick SampleSize random elements
Values
Specification of possible values
SampleSize
Integer
X
Output variable

Description

This predicate succeeds SampleSize times. Each time it succeeds, it returns a random value from the given specification of possible values. The Values specification are as in random_element/2.

Modes and Determinism

Examples

    ?- random_sample(0 .. 9, 3, X).
    X = 9
    Yes (0.00s cpu, solution 1, maybe more)
    X = 0
    Yes (0.03s cpu, solution 2, maybe more)
    X = 5
    Yes (0.03s cpu, solution 3)
    

See Also

random / 1, frandom / 1, random_element / 2, tent_set_random / 2