Functions - MASKOR/gologpp GitHub Wiki
In golog++
, functions are pure functional expressions.
That is, they must return some value of a non-void type, and they are side-effect free.
In particular, that means they are always made up of exactly one expression of the appropriate type, and nowhere can they contain any instructions like action calls or other things that may appear in a curly-braced code block.
Syntax
TYPE function NAME(TYPE arg1 [, TYPE arg2 ...]) = EXPRESSION_OF_TYPE
Examples
A function that returns the sum of two numbers:
number function plus(number lhs, number rhs) = lhs + rhs
A function that returns true if a number is greater than ten:
bool function gt10(number n) =
if (n > 10)
true
else
false
Alternative definition:
bool function gt10(number n) = n > 10