fredag, februari 03, 2006

Functions in Oracle Business Rules RL Language

The Oracle Business Rules RL Language syntax is very similar to Java, so it should be very easy for a Java programmer to get a grasp on the syntax quickly. If you have a background working with Jess, you will however notice that the syntax differs a bit. I will give a quick demonstration on the differences concerning functions.

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