Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
Komag
Level 9

Stack Overflow after only 31 recursive calls?

I'm just teasing, but c'mon, only 31? I thought it was supposed to be, like, millions! Smiley Tongue Smiley Surprisedops:
0 Kudos
2 Replies
EnTerr
Level 8

Re: Stack Overflow after only 31 recursive calls?

184 for me. Probably depends on what's stacked:
BrightScript Debugger> m.f = function(x): return x < 2 or m.f(x-1): end function
BrightScript Debugger> for ii = 1 to 1000: ? ii, m.f(ii): next
1 true
2 true
3 true
4 true
5 true
6 true
7 true
8 true
9 true
10 true
11 true
12 true
13 true
14 true
15 true
16 true
17 true
18 true
19 true
20 true
21 true
22 true
23 true
24 true
25 true
26 true
27 true
28 true
29 true
30 true
31 true
32 true
33 true
34 true
35 true
36 true
37 true
38 true
39 true
40 true
41 true
42 true
43 true
44 true
45 true
46 true
47 true
48 true
49 true
50 true
51 true
52 true
53 true
54 true
55 true
56 true
57 true
58 true
59 true
60 true
61 true
62 true
63 true
64 true
65 true
66 true
67 true
68 true
69 true
70 true
71 true
72 true
73 true
74 true
75 true
76 true
77 true
78 true
79 true
80 true
81 true
82 true
83 true
84 true
85 true
86 true
87 true
88 true
89 true
90 true
91 true
92 true
93 true
94 true
95 true
96 true
97 true
98 true
99 true
100 true
101 true
102 true
103 true
104 true
105 true
106 true
107 true
108 true
109 true
110 true
111 true
112 true
113 true
114 true
115 true
116 true
117 true
118 true
119 true
120 true
121 true
122 true
123 true
124 true
125 true
126 true
127 true
128 true
129 true
130 true
131 true
132 true
133 true
134 true
135 true
136 true
137 true
138 true
139 true
140 true
141 true
142 true
143 true
144 true
145 true
146 true
147 true
148 true
149 true
150 true
151 true
152 true
153 true
154 true
155 true
156 true
157 true
158 true
159 true
160 true
161 true
162 true
163 true
164 true
165 true
166 true
167 true
168 true
169 true
170 true
171 true
172 true
173 true
174 true
175 true
176 true
177 true
178 true
179 true
180 true
181 true
182 true
183 true
184 true
Stack overflow. (runtime error &hdf)
In any event i am proud of myself coming with a way to write a recursive function in B/S console. It's a doozy
0 Kudos
Komag
Level 9

Re: Stack Overflow after only 31 recursive calls?

Aha, well done. I've just barely learned some recursive stuff and was trying to implement part of my sound handling system, re-running the function if certain conditions aren't met using the next array element until they're gone. But I had a flag I was setting the wrong way, so it sent it into an endless recursion under a certain circumstance.
0 Kudos