View on GitHub

River Trail Interactive Shell

Powered by Ace and jq-console

/* Type some code here, then press the run button to load your code in the
 * console on the right. Below are some one-liners to get you started.
 */

/* Create your first array: */
var first = new ParallelArray(1,2,3,4);

/* Hit the run button and in the console, type "first" without quotes.
 * You will get the string representation of your first ParallelArray as output:
 * [1 2 3 4]
 */

/* Or you can create the same array using a comprehension */
var second = new ParallelArray(4, function (idx) { return idx+1; });

/* Some more idioms to play with: */

/* Increment */
var inc_pa = first.map(function (val) {return val+1;});

/* Add */
var add_pa = first.combine(function (idx,snd) {return this.get(idx)+snd.get(idx);}, second);

/* Sum */
var sum_pa = first.reduce(function (a, b) {return a + b;});

/* Expressions you put here will be evaluated and the results will
 * appear on the right.  Try it out!
 */
"Welcome to River Trail!"