ansuz.js
function(){ // the generator we will return
        var res=f(); // get the first result
        if(cond(res)&&failed){ // if we've failed twice, then we're done
            return; // return an undefined result
        }else if(cond(res)){ // otherwise, if we fail, try moving on
            f=function(){return next();} // now use the second list
            failed=true; // but remember that we failed once
            return fn(); // return the next element
        }else
            return res; // otherwise, we must have a good result, return it
    }
function(){ // the generator we will return
        var res=f(); // get the first result
        if(cond(res)&&failed){ // if we've failed twice, then we're done
            return; // return an undefined result
        }else if(cond(res)){ // otherwise, if we fail, try moving on
            f=function(){return next();} // now use the second list
            failed=true; // but remember that we failed once
            return fn(); // return the next element
        }else
            return res; // otherwise, we must have a good result, return it
    }
function ( ) { // the generator we will return var res = f ( ) ; // get the first result if ( cond ( res ) && failed ) { // if we've failed twice, then we're done return ; // return an undefined result } else if ( cond ( res ) ) { // otherwise, if we fail, try moving on f = function ( ) { return next ( ) ; } // now use the second list failed = true ; // but remember that we failed once return fn ( ) ; // return the next element } else return res ; // otherwise, we must have a good result, return it }
this keeps us from an infinite loop
this keeps us from an infinite loop