How to use tabling?

I’m trying to use tabling but running into an error with the example:

$ swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 7.6.4)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit http://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- consult("fib.pl").
ERROR: /home/sir/ailive/livebetter/phy_nlp/phy_nlp/prolog/fib.pl:2:9: Syntax error: Operator expected

where fib.pl is exactly as https://swish.swi-prolog.org/example/tabling.swinb and https://www.swi-prolog.org/pldoc/man?section=tabling-memoize:

:- table fib2/2.

fib2(0, 1) :- !.
fib2(1, 1) :- !.
fib2(N, F) :-
    N > 1,
    N1 is N-1,
    N2 is N-2,
    fib2(N1, F1),
    fib2(N2, F2),
    F is F1+F2.

Thanks in advance.

  • Stu
1 Like

You need a more recent SWI-Prolog version. For tabling, try the latest development version, 8.1.24.

1 Like

That worked. Thank you!