Prolog is neat, but I wouldn't use it for text processing and database access, so the logic programming piece to me makes better sense as embedded functionality in a more general purpose language, which is what I'm guessing you did here?
Prolog is neat, but I wouldn't use it for text processing and database access, so the logic programming piece to me makes better sense as embedded functionality in a more general purpose language, which is what I'm guessing you did here?
We can therefore apply operations like: [?X|?Z].
Finally, Tamgu considers that the reception variables before the "=" sign define the execution context. Therefore, if we take the following program:
parent ("John", "Peter").
parent ("John", "Mary").
parent ("Peter", "Roland").
parent ("Roland", "Pierre").
bool b = parent("John",?X);
vector v = parent(?X,?Y);
The first case will return "true" if we find a matching occurrence. Here "b==true".
The second case will return all the possibilities that match:
[parent("John", "Peter"),parent("John", "Mary"),parent("Peter", "Roland"),parent("Roland", "Pierre")
Access to each parameter is possible:
v[0] = parent ("John", "Peter")
v[0][1] == "Peter"
v[0].name() == "parent"
So "?X" is not true logical variable, but more of a part of a pattern expression? -- in other words, a logical var is a first-class object that can be stored in a data-structure (possibly in an unbound state) and be bound at a later time, and perhaps unbound and re-bound again if there is backtracking. So in Tamgu, "parent(?X,?Y)" acts as a one-shot "find" if the LHS is atomic, and acts as a generator (similar to a possibly nested list comprehension) if the LHS is a collection (but no inter-statement backtracking points are established), correct? So is the generation of the sequence eager/realized or lazy/by-need?
?X is actually a true Prolog variable that can be unified over and over again. Furtheremore, you can call Tamgu functions from your predicate description, in which these variables can be used if they are unified.
grandparent(?X,?Y) :- parent(?X,?Z), println(?Z), parent(?Z,?Y).
In the case above, the "println", which is not a predicate, will try to display the content of ?Z, if ?Z has been unified.
println could be replaced with a call to an actual function, as long as this function returns true. If the function returns false, then it will be considered as a fail.