martedì 23 febbraio 2010

Fortron automatic recursion

This amazing feature let you create functions with automatic recursion in it. I try to explain: you define a function, then executing some code in it and, randomly, the function calls itself with the last defined variables as parameters.

Check out this little example:

@autorecursion(probability=45%)
Fortrfunc autoexample(arg0, arg1) {
i is 1
a is 7
o ithinkis 8
arg0 fortrsum oai
arg1 fortrmul aio
}

In this case, with a probability of 45% this function calls itself with two among i, a, o, arg0, arg1 as parameters, but you don't know which of these, because the time of recall is also random.

Nessun commento:

Posta un commento