File tree Expand file tree Collapse file tree 1 file changed +20
-16
lines changed Expand file tree Collapse file tree 1 file changed +20
-16
lines changed Original file line number Diff line number Diff line change 1- var cartesianProduct = ( function ( ) {
1+ ( function ( exports ) {
22 'use strict' ;
3- var result ;
3+ var cartesianProduct = ( function ( ) {
4+ var result ;
45
5- function cartesianProduct ( sets , index , current ) {
6- if ( index === sets . length ) {
7- return result . push ( current . slice ( ) ) ;
6+ function cartesianProduct ( sets , index , current ) {
7+ if ( index === sets . length ) {
8+ return result . push ( current . slice ( ) ) ;
9+ }
10+ for ( var i = 0 ; i < sets [ index ] . length ; i += 1 ) {
11+ current [ index ] = sets [ index ] [ i ] ;
12+ cartesianProduct ( sets , index + 1 , current ) ;
13+ }
814 }
9- for ( var i = 0 ; i < sets [ index ] . length ; i += 1 ) {
10- current [ index ] = sets [ index ] [ i ] ;
11- cartesianProduct ( sets , index + 1 , current ) ;
12- }
13- }
1415
15- return function ( sets ) {
16- result = [ ] ;
17- cartesianProduct ( sets , 0 , [ ] ) ;
18- return result ;
19- } ;
20- } ( ) ) ;
16+ return function ( sets ) {
17+ result = [ ] ;
18+ cartesianProduct ( sets , 0 , [ ] ) ;
19+ return result ;
20+ } ;
21+ } ( ) ) ;
22+
23+ exports . cartesianProduct = cartesianProduct ;
2124
25+ } ( typeof exports === 'undefined' ? window : exports ) ) ;
You can’t perform that action at this time.
0 commit comments