Problem with Open Lists

Problem with Open Lists

Post by W D » Tue, 19 Jan 2010 13:57:23

I'm writing some code that recursively traverses through an open list.
Once I reach the end of the list, I'm having trouble distinguishing
between the following two cases:

Say the rule is foo(P). If I traverse through the list [a, b, c|_], in
my code, at the end it could be either P = _ or P = [c|_]. What I need
to do is write two foo() rules that capture the two different cases
(without changing the contents of P).

I tried is_list() but it doesn't work with open lists. Using length()
removes the open variable at the end.

Any ideas?

Problem with Open Lists

Post by Paulo Mour » Tue, 19 Jan 2010 18:29:54

Using var/1 to test the list tail?

Why do you need to use an open list?




Problem with Open Lists

Post by W D » Wed, 20 Jan 2010 13:47:24

Thanks Paulo, that worked.

I'm using open lists to implement feature structures in a linguistics
application: ~striegnk/courses/nlp-with-prolog/html/node84.html


Problem with Open Lists

Post by ulric » Wed, 20 Jan 2010 22:30:44

W D < XXXX@XXXXX.COM > writes:

Consider attributed variables for a serious implementation.