by jpt4 on 2/4/17, 5:13 AM with 157 comments
by arcfide on 2/5/17, 6:44 AM
If people express interest, I'll run such a live session and let people judge for themselves what they think of the code and my approach to "simplicity" after they've been introduced personally to the code base.
by natch on 2/4/17, 10:38 PM
...
rth,←' A zs;A rs=scl(r.v(0));rr##mf(zs,rs,p);if(c==1){z.v=zs.v;R;}\',nl
rth,←' array v=array(z.s,zs.v.type());v(0)=zs.v(0);\',nl
rth,←' DO(c-1,rs.v=r.v(i+1);rr##mf(zs,rs,p);v(i+1)=zs.v(0))z.v=v;)\',nl
rth,←' DL(zz,if(rr##scl){rr##df(z,l,r,p);R;}\',nl
...No.
And commit messages like "Hopefully that does it." No again.
by burgerdev on 2/4/17, 8:26 PM
Y0←{⊃,/((⍳≢⊃n⍵)((⊣sts¨(⊃l),¨∘⊃s),'}',nl,⊣ste¨(⊃n)var¨∘⊃r)⍵),'}',nl}
See also https://en.wikipedia.org/wiki/APL_(programming_language)#Exa...by franciscop on 2/4/17, 8:05 PM
// src/addclass/addclass.js
// Add class(es) to the matched nodes
u.prototype.addClass = function () {
return this.eacharg(arguments, function (el, name) {
el.classList.add(name);
});
};
While they don't do exactly the same (Umbrella JS is more flexible but jQuery supports IE9), compare that to jQuery's addClass(): addClass: function( value ) {
var classes, elem, cur, curValue, clazz, j, finalValue,
i = 0;
if ( jQuery.isFunction( value ) ) {
return this.each( function( j ) {
jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
} );
}
if ( typeof value === "string" && value ) {
classes = value.match( rnothtmlwhite ) || [];
while ( ( elem = this[ i++ ] ) ) {
curValue = getClass( elem );
cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
if ( cur ) {
j = 0;
while ( ( clazz = classes[ j++ ] ) ) {
if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
cur += clazz + " ";
}
}
// Only assign if different to avoid unneeded rendering.
finalValue = stripAndCollapse( cur );
if ( curValue !== finalValue ) {
elem.setAttribute( "class", finalValue );
}
}
}
}
return this;
},
by rakoo on 2/4/17, 7:56 PM
by finin on 2/4/17, 9:47 PM
by jcoffland on 2/5/17, 8:40 AM
by dude01 on 2/4/17, 9:04 PM
by skybrian on 2/5/17, 8:41 AM
by fourier on 2/13/17, 7:59 PM
by jfoutz on 2/5/17, 12:28 AM
by nattaylor on 2/4/17, 7:41 PM
I guess there's no such thing as "good enough" with a compiler?
Those are staggering numbers to me. Kudos to the author.
by arcfide on 2/13/17, 7:45 PM
by known on 2/5/17, 11:45 AM
by n0mad01 on 2/5/17, 12:46 AM
by edblarney on 2/5/17, 12:44 AM
I think 'simpler' would be a better term than 'smaller'.
Also - every line of code has cost. A lot of cost. Maintenance of code and complexity is not only expensive, but it adds to the maintenance of other code.
So less code to solve the problem is almost always better.