Previous: Built-in Operators, Up: Expressions


3.3 Function expressions

The HAC language supports function calls in expressions. Supported argument types and return types include integer, boolean, real (float, double), and strings.

— Fucntion: strcat args...
— Fucntion: sprint args...

Stringify all args and concatenate into a single string (returned). This can be used to convert argument types to a string. Does not include terminating newline.

— Function: bcond z a b
— Function: zcond z a b
— Function: rcond z a b
— Function: strcond z a b

Conditional expression, for boolean, integer, real, and string rvalues, respectively. If z is true, return a, else return b. NOTE: both expressions a and b are evaluated unconditionally.

— Function: zmin a b
— Function: zmax a b
— Function: rmin a b
— Function: rmax a b

Returns the minimum or maximum of two values. zmin and zmax take and return integers. rmin and rmax take and return reals.

— Function: strtoz str
— Function: strtob str
— Function: strtor str

Convert string str to an integer, boolean, real, respectively. Throws run-time exception if conversion fails.

— Function: rtoz real

Convert/cast real-value into integer value. Recommend calling ceil or floor before passing to this function.

— Function: ztor real

Convert/cast integer-value into real value.

The following math functions are exported from the vendor's libm library, which includes most symbols from <math.h>. Arguments and return types are real-valued unless noted otherwise.