How do I change two functions that are Mutual Recursive to each other to make them into a linear recursion? Do I have to have both the methods in a single method?
Asked
Active
Viewed 807 times
2
-
Perhaps you can illustrate with a short code sample what you're trying to achieve? – Johan Sjöberg Feb 09 '11 at 21:32
-
how did you manage to get mutual recursion in the 1st place? – bestsss Feb 09 '11 at 21:48
1 Answers
8
You should be able to simply "inline" the implementation of the second method, into the first method.
That is,
public static void methA() {
// snippet 1
methB();
// snippet 2
}
public static void methB() {
// snippet 3
methA();
// snippet 4
}
becomes
public static void methAB() {
// snippet 1
// snippet 3
methAB();
// snippet 2
// snippet 4
}
If the second method is long, and called from multiple points in the first method, it may get messy though.

aioobe
- 413,195
- 112
- 811
- 826