BEE Lisp Functions Reference

<list> DEFUN (name (formal_parameter_list) operators)

Declares function with specified name, formal parameter list (can be omitted), consisting of operators, and returns its body. Declared function is compiled into byte code of lisp virtual machine.

Example:

(DEFUN factorial (n)

     (

          COND ( (ISINTEGER n) 1 )  (1  (EXIT ( – 0 1) ) )

     )

     (

          COND ( (< n 0 ) (EXIT ( – 0 1))  )

     )

     (

          COND ( n ( IMUL n (factorial ( – n 1 ) ) ) ) (1 1)

     )

)

This function evaluates factorial of its parameter, checking whether it is positive integer (ISINTEGER). If so, factorial of that number is returned, otherwise –1 is returned. Function result is the result of last executed operator. For immediate exit from function EXIT function is used, which returns evaluation result of its parameter. Since EXIT is always the last executed function,  its result is the result of factorial function.