Except for a stupid typo in the wrapper generator, `:- table expr//1.`
already worked. Now it really works. There is a little but though:
:- table expr//1.
expr(id(a)) --> [a].
expr(A+B) --> expr(A), [+], expr(B).
E = id(a)+ (id(a)+id(a)) ;
E = id(a)+id(a)+id(a).
So far, so good! ... but
2 ?- print_existing_tables.
Yes, you get nice logically sound results. Quite often the price you
need to pay in terms of space in this case is large though. This is
probably in general the deception of tabling: it is nice way to reason
with complicated interrelated rules easily. It works great for one-shot
solutions in relatively small domains. It easily gets prohibitively
expensive in terms of memory usage once your domain gets bigger.
It is surely useful for some of the ICLP programming contest problems
though :) Last years problems were no longer solvable in pure Prolog.
This all must work before October :)
Cheers --- Jan
On 05/11/2016 12:59 AM, Markus Triska wrote:
> Hi all,
> in my view, one of the greatest benefits of tabling is that - at long
> last! - it enables us to parse /directly/ with left-recursive grammars.
> Like many more recent features of SWI-Prolog, tabling is another great
> example of a declarative enhancement that has great practical value, and
> makes countless beginners' questions completely obsolete or at least
> /far/ less pressing than they have been in the past.
> You received this message because you are subscribed to the Google
> Groups "SWI-Prolog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to swi-prolog+...@googlegroups.com
> Visit this group at https://groups.google.com/group/swi-prolog
> For more options, visit https://groups.google.com/d/optout