Calling blocks recursively

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Calling blocks recursively

STrookie
Hi together,

i'm trying since hours to call a block in Smalltalk recursively.
Can anybody help me with this ?
For example a want to write this JAVA function in Smalltalk:

public int calcNumber(int n) {
                int result = 0;
                if (n == 1) {
                        return 1;
                } else if (n == 2) {
                        return 1;
                } else {
                        result = calcNumber(n-1) + calcNumber(n-2);
                }
                return result;
        }

The if clauses aren't the problem, only the recursively call of: result = calcNumber(n-1) + calcNumber(n-2);
Can anybody help me with this ?