In Jess you create a function like:
Jess> (deffunction max (?x ?y)
(if (> ?x ?y) then
(return ?x)
else
(return ?y)))
and you call upon it with the following statement:
Jess> (printout t "The biggest number of 5 and 7 is: " (max 5 7) "." crlf)
In RL Language you create a similar function like:
RL> function max(long x, long y) returns long {
if (x<=y) { return y; }
else { return x; }
}
and you call upon it with the following statement:
RL> println("The biggest number of 5 and 7 is: " + max(5,7) + ".");
So, as you can see, with respect to functions, Jess and RL Language looks quite the same, however, there are syntactical differences for the programmer to be aware of.
Inga kommentarer:
Skicka en kommentar