27. Extensions
Numeric and range functions can be added simply by creating files in the source nf/ and rf/ subdirectories and recompiling. The first line of each function must be a comment specifying the number of return values, number of arguments, and description. The description will appear in the internal help listing and will also be included in the documentation after running make in the doc/ subdirectory.Source example, nf/atan2.c:
/* 1 2 four-quadrant arctangent, atan2(y,x) ~= atan(y/x) */ double nf_atan2(const Node *n, const Cell *c) { Node *r = Right(n); return atan2( eval_tree( r, c), eval_tree( r->next, c) ); }Constants can be added using install_constant() at the end of main() in parse.so:
install_constant( "HUGE_VAL", HUGE_VAL); install_constant( "DBL_EPSILON", DBL_EPSILON); install_constant( "RAND_MAX", RAND_MAX);