Author Archives: Dom Cimafranca
If Shakespeare wrote in JavaScript…
From If Hemingway wrote JavaScript:
function theSeriesOfFIBONACCI(theSize) {
//a CALCKULATION in two acts.
//employ'ng the humourous logick of JAVA-SCRIPTE
//Dramatis Personae
var theResult; //an ARRAY to contain THE NUMBERS
var theCounter; //a NUMBER, serv'nt to the FOR LOOP
//ACT I: in which a ZERO is added for INITIATION
//[ENTER: theResult]
//Upon the noble list bestow a zero
var theResult = [0];
//ACT II: a LOOP in which the final TWO NUMBERS are QUEREED and SUMM'D
//[ENTER: theCounter]
//Commence at one and venture o'er the numbers
for (theCounter = 1; theCounter < theSize; theCounter++) {
//By divination set adjoining members
theResult[theCounter] = (theResult[theCounter-1]||1) + theResult[Math.max(0, theCounter-2)];
}
//'Tis done, and here's the answer.
return theResult;
//[Exuent]
}
Intel Software Network: Superscalar Sequences and Task Graphs
Interesting blog series on parallel programming. The first post is on Superscalar Sequences and Task Graphs.
The “superscalar sequence” pattern is related to the idea of “futures”. Futures are objects that explicitly represent in-progress asynchronous computations and typically provide the ability to check for completion with or without blocking. Futures may also provide operations to check completion percentages of computations and to cancel operations in progress. Futures are also occasionally useful for fine-grained control of asynchronous operations, but in general future-like controls can also be built into the data objects of the sequence pattern and only invoked when necessary.