hi, i have a problem which recursion fits perfectly, however; after working with the base function (which has no errors and works correctly) the recursions return a "function not defined" error in ff's js console. i tried a few things that came to mind but nothing has changed it... i found some interesting articles on the net regarding javascript's callbacks, and found out that due to callbacks recursion may end up eating a lot more memory than normal recursion does, which makes it sound like js and recursion don't go together.
the second time i call value1(), when it is in the first loop of the recursive function, i get the 'function not defined' error. i also get a not defined error regarding the chars string on that same line if you get past the function error. i'm guessing its related...
any help is appreciated.
<script type="text/javascript">
var chars = "abcdefghijklmn opqrstuvwxyzABC DEFGHIJKLMNOPQR STUVWXYZ";
function value1(baseChar , base, options) {
this.baseChar = baseChar;
this.base = base;
if(options == "")
this.valid = new Array(0);
else {
this.valid = new Array(0);
for(var i=0; i<options.lengt h; i++)
this.valid.push (options.substr ing(i,i+1));
}
this.child = new Array(0);
}
function mod() {
var aNum = 0;
var input = "\"eHgMYUn_ MWW[SLZ!kKOiM\\SX[Uif'GcaO]YU`eWPJIv|g`YTV TlrUPQT`R_T MgIO~pcM[QHaQVrYI^u'f,ue HgMYU,";
var v1opt = new value1("", 0, chars);
recurse1(v1opt) ;
}
function recurse1(v1opt) {
document.write( "base char: "+ v1opt.baseChar +"<br />");
document.write( "base: "+ v1opt.base +"<br />");
document.write( "valid: "+ v1opt.valid.joi n() +"<br />");
for(var i=0; i<v1opt.valid.l ength; i++) {
if((v1opt.base + v1opt.valid[i].charCodeAt(0)) <= 1286) {
document.write( "child: "+ v1opt.valid[i].charAt(0) +"<br /><blockquote>") ;
var a = new value1("", 0, chars);
child = v1opt.child.pus h(a);
for(var j=0; j<chars.length ; j++)
if((child.base + chars.charCodeA t(j)) <= 1286)
child.valid.pus h(chars.charAt( j));
}
}
if(v1opt.child. length != 0)
for(var i=0; i<v1opt.child.l ength; i++)
recurse1(v1opt. child(i));
document.write( "</blockquote>");
}
the second time i call value1(), when it is in the first loop of the recursive function, i get the 'function not defined' error. i also get a not defined error regarding the chars string on that same line if you get past the function error. i'm guessing its related...
any help is appreciated.
<script type="text/javascript">
var chars = "abcdefghijklmn opqrstuvwxyzABC DEFGHIJKLMNOPQR STUVWXYZ";
function value1(baseChar , base, options) {
this.baseChar = baseChar;
this.base = base;
if(options == "")
this.valid = new Array(0);
else {
this.valid = new Array(0);
for(var i=0; i<options.lengt h; i++)
this.valid.push (options.substr ing(i,i+1));
}
this.child = new Array(0);
}
function mod() {
var aNum = 0;
var input = "\"eHgMYUn_ MWW[SLZ!kKOiM\\SX[Uif'GcaO]YU`eWPJIv|g`YTV TlrUPQT`R_T MgIO~pcM[QHaQVrYI^u'f,ue HgMYU,";
var v1opt = new value1("", 0, chars);
recurse1(v1opt) ;
}
function recurse1(v1opt) {
document.write( "base char: "+ v1opt.baseChar +"<br />");
document.write( "base: "+ v1opt.base +"<br />");
document.write( "valid: "+ v1opt.valid.joi n() +"<br />");
for(var i=0; i<v1opt.valid.l ength; i++) {
if((v1opt.base + v1opt.valid[i].charCodeAt(0)) <= 1286) {
document.write( "child: "+ v1opt.valid[i].charAt(0) +"<br /><blockquote>") ;
var a = new value1("", 0, chars);
child = v1opt.child.pus h(a);
for(var j=0; j<chars.length ; j++)
if((child.base + chars.charCodeA t(j)) <= 1286)
child.valid.pus h(chars.charAt( j));
}
}
if(v1opt.child. length != 0)
for(var i=0; i<v1opt.child.l ength; i++)
recurse1(v1opt. child(i));
document.write( "</blockquote>");
}
Comment