Search code examples
randomprologwin-prolog

WIN-PROLOG - how to get random value?


I'm using LPA WIN-PROLOG and I want to get random values. I looked for a random predicate and I don't find one that is already defined. What I tried:

X is random(10)

random(1,10,X)

Can someone help me find the way to get a random value?

Thanks.


Solution

  • LPA Win-Prolog provides a rand/1 built-in function and a seed/1 predicate to get/set the seed of the random number generator. The rand/1 function returns a float between zero and its argument. For example:

    ?- seed(42), Random is rand(10).