Did you know ... Search Documentation:
Pack canny_tudor -- prolog/docker/random_names.pl
PublicShow source
 random_name(?Name) is nondet
Non-deterministically generates Docker-style random names. Uses random_permutation/2 and member/2, rather than random_member/2, in order to generate all possible random names by back-tracking if necessary.

The engine-based implementation has two key features: generates random permutations of both left and right sub-names independently; does not repeat until after unifying all permutations. This implies that two consecutive names will never be the same up until the boundary event between two consecutive randomisations. There is a possibility, albeit small, that the last random name from one sequence might accidentally match the first name in the next random sequence. There are 23,500 possible combinations.

The implementation is not the most efficient, but does perform accurate randomisation over all left-right name permutations.

Allows Name to collapse to semi-determinism with ground terms without continuous random-name generation since it will never match an atom that does not belong to the Docker-random name set. The engine-based non-determinism only kicks in when Name unbound.

 random_name_chk(-Name:atom) is det
Generates a random Name.

Only ever fails if Name is bound and fails to match the next random Name, without testing for an unbound argument. That makes little sense, so fails unless Name is a variable.

 random_name_chk(?LHS:atom, ?RHS:atom) is semidet
Unifies LHS-RHS with one random name, a randomised selection from all possible names.

Note, this does not naturally work in (+, ?) or (?, +) or (+, +) modes, even if required. Predicate random_member/2 fails semi-deterministically if the given atom fails to match the randomised selection. Unifies semi-deterministically for ground atoms in order to work correctly for non-variable arguments. It collapses to failure if the argument cannot unify with random-name possibilities.