Hi Cle,

> And till now, I am failing to get a solution, that works for both
> examples. I think the problem may be, that in the first example, the
> free argument '@Var' is unified with the free variable '@C'. But in the
> second example, '@Var' is bound to '(@C @N)'. Those both seem to work
> different.

Yes, looks like. The binding to '@Var' had already happened before
exeuction starts.


> In some Prolog dialects, there is a predicate 'free/1' and 'bound/1'
> that succeed, if the passed variable was free or bound. Unfortunately, I
> found no such check in Pilog.

There is currently no such predicate. Only '->', but this doesn't
distinguish between "value is NIL" and "not bound".


> 1. Is it possible to complete 'findall' more elegantly to work with both
> one as well as with more than one variable?
> 2. Is it possible to check in Pilog whether a certain variable is free
> or already bound?

Thinking about it a little, I came up with a "half" solution:

   (be tst (@Var (@Pred . @Args))
      (call @Pred . @Args)
      (@ unify (-> @Var)) )

   : (? (tst @C (ascii @C @N)))
    @C=a
    @C=b
    @C=c
   -> NIL

   : (? (tst (@C @N) (ascii @C @N)))
    @C=a @N=97
    @C=b @N=98
    @C=c @N=99
   -> NIL

At the moment, however, I don't know how to get the bindings into a
single result list. I'm sure you know how to make a recursive predicated
that accomplishes that ;-)


As my Prolog skills are rather poor, I would more easily come up with a
Lisp solution. For the problem at hand, it might be useful to know
that the clauses are stored under the 'T' property of 'ascii':

   : (get 'ascii T)
   -> (((a 97)) ((b 98)) ((c 99)))

What is the concrete problem? You might be able to solve it directly
(and more efficiently) by accessing that list.

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to