Algebra.js
function(term, any) {
                    var max = Math.max.apply(null, term.terms),
                        count = 0, idx;

                    if(!any) {
                        for(var i=0; i<term.terms.length; i++) {
                            if(term.terms[i].equals(max)) {
                                idx = i; count++;
                            }
                            if(count > 1) return;
                        }
                    }
                    if(any) {
                        for(i=0; i<term.terms.length; i++) 
                            if(term.terms[i].equals(max)) {
                                idx = i; break;
                            }
                    }
                    return [max, idx, term];
                }
function(term, any) {
                    var max = Math.max.apply(null, term.terms),
                        count = 0, idx;

                    if(!any) {
                        for(var i=0; i<term.terms.length; i++) {
                            if(term.terms[i].equals(max)) {
                                idx = i; count++;
                            }
                            if(count > 1) return;
                        }
                    }
                    if(any) {
                        for(i=0; i<term.terms.length; i++) 
                            if(term.terms[i].equals(max)) {
                                idx = i; break;
                            }
                    }
                    return [max, idx, term];
                }
function ( term , any ) { var max = Math . max . apply ( null , term . terms ) , count = 0 , idx ; if ( ! any ) { for ( var i = 0 ; i < term . terms . length ; i ++ ) { if ( term . terms [ i ] . equals ( max ) ) { idx = i ; count ++ ; } if ( count > 1 ) return ; } } if ( any ) { for ( i = 0 ; i < term . terms . length ; i ++ ) if ( term . terms [ i ] . equals ( max ) ) { idx = i ; break ; } } return [ max , idx , term ] ; }
Silly Martin. This is why you document. I don't remember now
Silly Martin . This is why you document . I don t remember now