The Cartesian product of JS implementations-product launches

Source: Internet
Author: User

//Cartesian product combinationfunctionDescartes (list) {//Parent top-level index; count Pointer counts    varPoint = {}; varresult = []; varPindex =NULL; varTempcount = 0; vartemp = []; //to generate a pointer object from a parameter column     for(varIndexinchlist) {        if(typeofList[index] = = ' object ') {Point[index]= {' Parent ':p index, ' count ': 0} pindex=index; }    }     //single-dimensional data structures are returned directly    if(Pindex = =NULL)    {        returnlist; }     //dynamically generated Cartesian product     while(true)    {         for(varIndexinchlist) {Tempcount= point[index][' Count '];        Temp.push (List[index][tempcount]); }         //Press-in result arrayResult.push (temp); Temp= []; //Check for pointer max problems         while(true)        {            if(point[index][' count ']+1 >=list[index].length) {point[index][' count '] = 0; Pindex= point[index][' Parent ']; if(Pindex = =NULL)                {                    returnresult; }                 //Assign the parent to check againindex =Pindex; }            Else{point[index][' Count ']++;  Break; }        }    }}//The code snippet is from: http://www.sharejs.com/codes/javascript/7013varaa=[1,2,3],bb=[1,2,3],cc=[1,2,3],dd=[1,2,3];varZZ=[AA,BB,CC,DD];//any number of arrays herevarSelectspec = [[' 16G ', ' 64G ', ' 128G '], [' Local tyrants Gold ', ' silver ', ' black ', ' Pink '],[' unicom 3G deposit delivery meal ', ' unicom 4G storage fee delivery ', ' Unicom 2G storage fee delivery '], [' 76 RMB package ', ' 106 RMB package ' , ' 206 RMB package ']]; varresult=Descartes (Selectspec); Console.log (Result);d ocument.write (result);

The Cartesian product of JS implementations-product launches

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.