Functions

A function is a procedure for transferring value to place your call. Jess lets you define your own functions that perform a task written by the programmer. Let's create a function with command (deffunction ()).

(deffunction poleTrojkata (?a ?h)
(bind ?pole (/ (* ?a ?h) 2))
(printout t "Pole wynosi " ?pole crlf))

;wywolanie funkcji
(poleTrojkata 2 3)

I introduced a simple function counting area of a triangle. Note the way to write an arithmetic operation. If it is incomprehensible to you go back to the page describing the basic commands. .

This function takes two arguments a - the length of the base and h - height. It then assigns to the variable field value of the expression. This is followed by printing result on the screen. The last line shows call of the function, be sure to include relevant arguments.

Practicing writing try to write such a function that will count area of several figures.