|Did you know ...||Search Documentation:|
Obj:Attr = Valueconstruct is not accepted.
__iter__on the result to get the iterator itself.
__next__function of the iterator.
The example below uses the built-in iterator
?- py_iter(range(1,3), X). X = 1 ; X = 2.
Note that the implementation performs a look ahead, i.e., after successful unification it calls `__next__()` again. On failure the Prolog predicate succeeds deterministically. On success, the next candidate is stored.
Note that a Python generator is a Python _iterator. Therefore,
given the Python generator expression below, we can use
py_iter(squares(1,5),X) to generate the squares on backtracking.
def squares(start, stop): for i in range(start, stop): yield i * i
|Options||- is processed as with py_call/3.|