get or set the current or maximal allowed depth of nested calls
currentMaxDepth = recursionlimit() formerMaxDepth = recursionlimit(newMaxDepth) currentDepth = recursionlimit("current")
Maximal number of nested calls (= depth) currently set.
New maximal number of nested calls to set.
Former value set, before it was changed
input keyword retrieving the current calling depth (before reaching the max one).
Current calling depth.
Use this function to change the maximal number of nested calls allowed in Scilab. Each script.sce, public or internal (like overloads) functions in Scilab language, or built-in functions compiled from an external language is a level. Default value is set to 1000 levels.
![]() | newMaxDepth can be set in Scilab preferences. |
recursionlimit(20); function testRecursion() printf("recursion: %d\n", recursionlimit("current") - 1); testRecursion; endfunction testRecursion; | ![]() | ![]() |
//show that cos and %rec_cos increment the current recursion level. recursionlimit(40); function %rec_cos(val) printf("recursion: %d\n", recursionlimit("current") - 1); val.count = val.count + 1; //disp(val.count); cos(val); endfunction a = tlist(["rec", "count"], 0); cos(a) | ![]() | ![]() |
recursionlimit(10); function [out]=recfib(in) printf("recursion: %d\n", recursionlimit("current") - 1); if in == 1 then out = 1; elseif in == 2 out = 1; else out = recfib(in-1) + recfib(in-2); end endfunction recfib(10); //OK recfib(11); //KO | ![]() | ![]() |
Version | Description |
6.0.0 | Function added |