DocGrimwig Posted September 23, 2015 Share Posted September 23, 2015 I have been trying to apply the theory of recursion to practical application within a JS function. At first I thought it would be easy. I have found several attempts, but most are all over the place and it's hard to follow them and to learn something from them. I have spent days with others, only to discover they are not using proper JS protocols. Can anyone link me to a GREAT Word Combination (recursive, repeating) -permutations, JS function that finds all of the combinations of an input word and displays them in the browser? I am so new that I can't tell what's good or what's bad. Thanks! Doc Link to comment Share on other sites More sharing options...
justsomeguy Posted September 23, 2015 Share Posted September 23, 2015 That's a pretty specific request. I'm not sure I understand, it doesn't sound like you would need recursion for that. The classical example of recursion is a factorial function though, that's about as basic as it gets even though the real-world application is pretty limited. A real-world example of recursion is to print out an entire directory structure. In a Javascript context, you could start with a JSON structure representing the directory rather than reading the structure straight from disk. You could even have PHP generate that JSON structure based on your actual file structure, which will use recursion in PHP also. Link to comment Share on other sites More sharing options...
DocGrimwig Posted September 23, 2015 Author Share Posted September 23, 2015 I'm so new to this. I'm an idiot "justsomeguy." I don;t need recursion after all, I am thinking incorrectly. I just need to get it accomplished. I feel stupid. Link to comment Share on other sites More sharing options...
davej Posted September 24, 2015 Share Posted September 24, 2015 ...a ... function that finds all of the combinations of an input word and displays them in the browser? Is this what you mean? dog dgo odg ogd gdo god Link to comment Share on other sites More sharing options...
DocGrimwig Posted September 24, 2015 Author Share Posted September 24, 2015 yes Link to comment Share on other sites More sharing options...
justsomeguy Posted September 24, 2015 Share Posted September 24, 2015 Those are permutations, I'm not sure what you mean by combinations not permutations. There's a recursive permutation algorithm here with a brief explanation:http://stackoverflow.com/questions/14008521/please-explain-this-algorithm-to-get-all-permutations-of-a-string Link to comment Share on other sites More sharing options...
DocGrimwig Posted September 24, 2015 Author Share Posted September 24, 2015 I understood permutations to mean: d, o, g, do, od, dg, gd.....dog, dgo, odg ect... So what is the above?? Link to comment Share on other sites More sharing options...
justsomeguy Posted September 24, 2015 Share Posted September 24, 2015 No, a permutation includes all members of the set, in this case all letters of the word. I'm not sure what the term for that other arrangement is. Link to comment Share on other sites More sharing options...
DocGrimwig Posted September 24, 2015 Author Share Posted September 24, 2015 Thanks. It is such a big mtn to climb. Thanks for your help. Any opinion on should I learn something like Angular.js to bootstrap etc? And if so, before I do .js or after? Link to comment Share on other sites More sharing options...
justsomeguy Posted September 25, 2015 Share Posted September 25, 2015 I suppose if they can help you, then learn them. I don't use Angular, I'm not a huge fan of basically using another language to try and abstract something that doesn't really need to be all that abstract. Bootstrap is fine to learn if you're trying to make device responsive sites. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now