Subject: tree and _X

From: "Waseem Besada" <[email-masked]>
Date: Fri, 15 Sep 2000 12:23:33 +0200

What is wrong in this fragment of Prolog: ( Thinking in dictionary, that is
a map of pairs Key -> Value)

tree(Key, Value, Left, Right).
lookup(Key, tree(Key1, Value1, Left, Right), Value) :-
Key < Key1, lookup(Key, Left, Value).
lookup(Key, tree(Key1, Value1, Left, Right), Value) :-
Key > Key1, lookup(Key, Left, Value).

?- Dict=tree(1, ko, _C, tree(2,katt,_B,_A)), lookup(1,Dict,V),
lookup(2,Dict,W).

The answer is No while I should get (as I beleive):
V= ko, W=katt.

Why ?

another question:

What is the difference between a variable wriiten as X and _X ?

Regards,
Waseem