Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3273310
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:55:06+00:00 2026-05-17T18:55:06+00:00

So, I have a template string with X amount of tokens in it. Hypothetically

  • 0

So, I have a template string with X amount of tokens in it. Hypothetically it could look like this:

template = "render=@layer0@-@layer1@-@layer2@-@layer3@-@layer4@"

The tokens, obviously, take the form of @tokenname@. In this hypothetical case it has five tokens. Each token has a different set of possible values. For example:

token0Values = ['t0value1'];
token1Values = ['t1value1','t1value2'];
token2Values = ['t2value1','t2value2','t2value3'];
token3Values = ['t3value1','t3value2'];
token4Values = ['t4value1','t4value2','t4value3','t4value4'];

My question then is, how do I generate every possible permutation of the string given the template and the possible values for each token?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:55:07+00:00Added an answer on May 17, 2026 at 6:55 pm

    I’ll take a stab at it in sorta php/AS

    tokens is a two dimensional array of possible values

    {
    [0] = “apple”,”banana”,”pear”
    [1] = “carrot”,”pea”
    [2] = “potato”, “celery”, “butter”,”gravy”
    }

    function getPermutations(tokens){
    
           var perms = array();
    
           //exit condition : there's only one token; 
           //total permutations = values array
           //so just return it
    
           if (tokens.length == 1)
               return tokens[0];
    
           //otherwise  
           //strip 1st element of the array as your "prefix"   
    
           prefices= tokens.shift();
    
           //get the permuations of the children
    
           childPermutations = getPermutations(tokens);
    
           //loop through the possible values, or "prefices"
    
           foreach (prefices as prefix){
    
                //concatenate to each of the child permutations
    
                foreach(childPermutations as perm)
                    perms[]=prefix + perm;
           }
    
           //return the glob
           return perms;
    }
    

    that might work, or something similar

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have template that looks like this: 100 template<size_t A0, size_t A1, size_t A2,
I may have string like, Hello, %(name)s, how are you today, here is amount
I have some template string this is my {0} template {1} string which I
In my Java app I have a template string, say, This record's name is
Currently, I have some code as follows template<typename Type> Type* getValue(std::string name, bool tryUseGetter
I have this snippet of code private Templates retrieveFromCache(String name) { TemplatesWrapper t =
I have a template class method like that: template<class T> static tmpClass<T>* MakeInstance(T value)
I have this class in my model: class ServiceCharge(models.Model): name = models.CharField(max_length=30) amount =
Let's assume I have the following file - template.php : <?php $string = 'Hello
I have a WebInvoke method like this; [OperationContract] [WebInvoke( Method = POST, UriTemplate =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.