Next: , Previous: , Up: Syntax [Contents][Index]


4.5 Function calls

A function call is a either simple compound term where the functor is the name of a primitive or program defined function, or it is a non-simple compound term where the compound term that denotes the functor is a function call that returns a function value.

For certain binary primitive functions the functor name may be used as an infix operator and placed between the two arguments. This holds for the usual binary arithmetic operators +, * etc. for which function applications are written as expressions such as 6+9*X.

The special zero argument functions e and pi, invoked as in expressions e() and pi(), evaluate to the numbers ’e’ and ’pi’. More details are given in Arithmetic Functions and Relations.

In the QuLog interpreter a function call, indeed any expression, can be given as a unification problem to be evaluated.

Examples:

| ?? X = 67.7/2.3.

X = 29.4348 : num

| ?? X = curryR(child_of)(tom).

X = curryR(child_of)(tom) : term_naming(rel(?human))

% The denoted value (term) is a relation over humans.

Function calls denote expressions that contain no function calls. That is they denote non-variable terms: atomic values, code names, simple compound terms all the arguments of which are non-variable terms, lists or sets of non-variable terms. The exceptions are certain code returning function calls which are only evaluated when the code value they denote is itself called. The above curryR(child_of)(tom) is an example. It denotes an unary relation but that relation is only used when the unary relation is called in a query such as:

| ?? P :: Rel=curryR(child_of)(tom) & Rel(P).

P = roger : man

Next: , Previous: , Up: Syntax [Contents][Index]

On This Site