LSL Wiki Mirror 7-7-7 : recursion

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings ::

Recursion


Recursion is a programming method in which a routine calls itself. Recursion is an extremely powerful concept, but it can strain a script's memory allocation.

subtractTillTwo(integer value) {
    if (value > 2) {
        subtractTillTwo(value - 1);
    } else if (value == 2) {
        llSay(0, "Value is two!");
    }
}

default {
    state_entry() {
        subtractTillTwo(35);
    }
}

To determine a script's memory usage: llGetFreeMemory


script | memory
There are 3 comments on this page. [Display comments/form]