In Prolog, solutions to queries are given as bindings which map
variable names into Prolog terms. A programmer using Pengines in a
JavaScript evironment needs to understand how bindings are converted
into JSON. For example, the programmer needs to understand that the
second solution to
append(Xs, Ys, [a,b,c]) is given by the bindings
['Xs'=[a],'Ys'=[b,c]] and that these binding can be
represented in JSON as {"Xs":["a"], "Ys":["b","c"]}.
Pengines defines the following mapping between ground Prolog terms and JSON.
@(true) and @(false) are
mapped to the JSON constants true and false,
respectively.@(null) is mapped to the JSON constant null.json(NameValueList), where NameValueList
is a list of Name=Value pairs, is mapped to a JSON object.{"functor": F, "args": A} where F
is a string representing the functor of T and A is
the list of JSON values representing Ts arguments.