torsdag, april 06, 2006

Recursion in RL Functions

Today I was thinking if it were possible to create recursive functions in the RL Language, so I made a small test by calculating factorials. I started by defining the function as:

function factorial(long x) returns long {
if( x == 1) {
return 1;
} else {
return x*(factorial( x-1 ));
}
}

Next, I just ran it by using:

println("The factorial of 12 is: " + factorial(12) + ".");

and this gave me the expected result of:

The factorial of 12 is: 479001600.

so, this seems to work fine.

Next thing will be to try recursion for facts, and of course for rules... More about that later.

måndag, april 03, 2006

Site Feeds

Added links to Atom and RSS feed links in the Links section. They are also available here:

Atom Site Feed
RSS Site Feed