jan's home page logic programming previous next latest

Prolog in Javascript

Version four finally brings bagof/3 to life. Included here (finally) is the fix to the renameVariables bug that meant using numerics in a variable's name was asking for trouble.

As per usual when free variables aren't made explicit, you can use bagof/3 to write var/1; details are left to the interested reader (but note the behaviour of test3 below when the second parameter is supplied as a variable).

This can (could) be fixed by noticing when we're bringing in variables from outside the expression - currently we leave it behaving exactly as bagof/3 in prolog does.

Enter your query: