Javascript
CA
If Hemingway Wrote JavaScript: Explained.
[]
JavaScript, JavaScript
I wrote a book called If Hemingway Wrote JavaScript in which I imagine 25 famous novelists, poets and playwrights solving simple problems in JavaScript.
Lewis Carrollhttps://github.com/angus-c/literary.js/tree/master/book/carroll/prime.jsfunction downTheRabbitHole(growThisBig) { var theFullDeck = Array(growThisBig); var theHatter = Function('return this/4').call(2*2); var theMarchHare = Boolean('The frumious Bandersnatch!
Let’s take another look at his code://into the pool of tears... eval(theFullDeck.join('if (!theFullDeck[++theHatter]) {\ theMarchHare = 1;\ theVerdict.push(theHatter);\ ' + theFullDeck.join('theFullDeck[++theMarchHare * theHatter]=true;') + '}') );The argument to eval resolves (after formatting) to:if (!theFullDeck[++theHatter]) { theMarchHare = 1; theVerdict.push(theHatter); theFullDeck[++theMarchHare * theHatter] = true; theFullDeck[++theMarchHare * theHatter] = true; theFullDeck[++theMarchHare * theHatter] = true; } if (!theFullDeck[++theHatter]) { theMarchHare = 1; theVerdict.push(theHatter); theFullDeck[++theMarchHare * theHatter] = true; theFullDeck[++theMarchHare * theHatter] = true; theFullDeck[++theMarchHare * theHatter] = true; } if (!theFullDeck[++theHatter]) { theMarchHare = 1; theVerdict.push(theHatter); theFullDeck[++theMarchHare * theHatter] = true; theFullDeck[++theMarchHare * theHatter] = true; theFullDeck[++theMarchHare * theHatter] = true; } // etc...…and so on.
[] is equivalent to true + true.
JavaScript) reach the second quadratic and again the result is assigned to the (existing) variable n. */ n = 3*i*i + j*j; /* Although the variable (i.e.
['number'
'true'
'array'
'prime'
'explained'
'function'
'var'
'javascript'
'hemingway'
'wrote'
'thehatter'
'j'
'n']