This may seem like an odd question that could simply be answered by the findall/3
predicate. However my problem is a little deeper than that.
So I have a predicate called ran_num/1
that returns one of five random numbers (that is I do not know what the numbers could be but there are only 5 of them).
When I run the predicate it returns this output as an example:
?- ran_num(X).
X = 2
?-
Note that there are no alternative answers, pressing ;
will do nothing. Prolog is awaiting another query command.
If I run findall on this the result is:
?- findall(X, ran_num(X), L).
L = [2]
?-
Is there an inbuilt predicate or method I can implement that will get me all the possible numbers that can be generated? So for example I can get a list which is [2,60,349,400,401].
Assume I cannot change the ran_num/1
predicate to give me alternatives.
Aucun commentaire:
Enregistrer un commentaire