/// Returns the text reversed, recursively.
String reverse(String text) {
    if (text.length() <= 1) {
        return text;
    }
    return reverse(text.substring(1)) + text.charAt(0);
}

void main() {
    IO.println(reverse("recursion"));
}

// From Groundwork, chapter 12 (ch12-recursion-and-problem-solving), box 5.
// This example is from Groundwork, licensed CC BY-NC-SA 4.0.
// Run with: java ch12_05.java
