How can I call a function random inside other function in prolog?

686 Views Asked by At

I'm trying to call the random function inside another function. For example I want to do this assert(fact(random()). But it does not work. How can I insert a random number this way? Thanks.

1

There are 1 best solutions below

1
On BEST ANSWER

In prolog there is no concept of functions like you are trying to do in your code. You should do:

random(N), assert(fact(N))

I recommend reading at least first two chapters Learn Prolog Now! to better understand search and unification.