Succeeds if the first argument can be unified with a randomly selected element of the list represented by the second argument.
Examples
?- random_member(X, []).
no
?- random_member(X, [a]).
X = a
yes
?- random_member(a, [X]).
X = a
yes
?- random_member(a, [a]).
yes
?- repeat, random_member(a, [a, b, c]), !.
yes;
no
?- repeat, random_member(b, [a, b, c]), !.
yes;
no
?- repeat, random_member(c, [a, b, c]), !.
yes;
no
?- random_member(d, [a, b, c]).
no
?- random_member(X, Y).
Expected second argument to be a list but got: Y
?- random_member(a, [b|_]).
Expected second argument to be a list but got: .(b, _)