/* Benchmark fib in Picat v3. From bench/fib.pl https://github.com/SWI-Prolog/bench.git Changes: - changed abolish_all_tables to initialize_table - changed table fib/2 to table - added println/1 This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ main => go. go ?=> initialize_table, fib(1000,N), println(N), fail, nl. go => true. % Tabling is also important for the memoisation it offers. % The standard example is calculating Fibonacci numbers. % % As an example, this benchmark calculates the N-th Fibonacci number without tabling. % You can compare its execution time to the version with tabling in fib-no-tabling-hprolog.pl % % This is also interesting for a paper (Marko, Tom). top :- % abolish_all_tables, initialize_table, fib(1000,_), fail, nl. top. % :-table fib/2. table fib(0, 1) :- !. fib(1, 1) :- !. fib(N,F):-N>1,N1 is N-1, N2 is N-2,fib(N1,F1),fib(N2,F2),F is F1+F2.