i am searching for a possibility to transform this code
zero(0).
positive(X) :- \+ zero(X).
so that calls like
?- positive(X).
will generate values for X.
Actually only calls with specific values for X are tested correctly but no values can be generated.
Thanks.
You could write virtually straightforward
and this indeed will work
but have in mind, that being not tail-recursive this algorithm is exponentially complex.
I mean:
Note the time for generation of 4000 positives.
But if we right it like:
All works fast now: