jPaq Example - Cartesian Product

A few weeks ago, I came across a question about finding the cartesian product of two or more arrays in JavaScript.  The following is the code to do it, using jPaq's Array.prototype.reduce() and Array.prototype.forEach() functions:

The following is an executable example which uses this function to find the cartesian product of arrays:

Applicable Parts

Related Examples

  1. Currying
    At times, you may want to call a function a number of times, but you may notice that the first few arguments are always the…
  2. Counting Squares On A Checker Board
    How many squares are there on a checker board?  Most people would say there are only 64 squares, but others would say what about…
  3. Reducing to the Longest Word
    Enter as many words as you want in the textbox below and then press the "Get Longest Word Length" button to see how many characters…
  4. Flatten Arrays
    One of the nice functions that is provided in Prototype is Array.prototype.flatten().  It gives you the ability to turn arrays such as…