Hacker News new | past | comments | ask | show | jobs | submit login

Congrats @clauderoux! -- I've been working on similar fusions on and off during the years.

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?




Exactly. If you provide a collection, the system will deduce that you want all solutions to be extracted, while if you provide a non collection variable then it will stop once one solution has been found. Actually, I have a very specific type, which is "predicatevar", if you want to get your unification once.

?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.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: