This is what I have so far..

<cffunction name="createWordList" returntype="array">
       <cfargument name="wordArray" required="yes" type="array" />
       <cfargument name="strbase" default="" required="yes" type="string" />
       <cfargument name="remainingchars" default="" required="yes"
type="string" />

       <cfset var j = 1 />
       <cfset var currchar = "" />

       <cfscript>
       if(len(remainingchars) eq 1) {
               wordArray[ArrayLen(wordArray)+1] = strbase &
mid(remainingchars,1,1);
       } else {
               for (j = 1; j lt len(remainingchars); j=j+1) {
                       currchar = mid(remainingchars,j,1);
                       if(find(currchar,remainingchars,j) eq j) {
                               arrayappend(wordArray,
mid(remainingchars,1,j) &
mid(remainingchars,j+1,len(remainingchars)));
                               //createWordList(wordArray, strbase &
mid(remainingchars,1,j), mid(remainingchars,1,j) &
mid(remainingchars,j+1,len(remainingchars)));
                               //wordArray = createWordList(wordArray,
strbase + remainingchars.charAt(j), remainingchars.substring(0, j) +
remainingchars.substring(j+1, remainingchars.length)); //recursive
call
                               }
               }
       }

       </cfscript>
<cfreturn wordArray />
</cffunction>

The specific part I'm having problems with is
                               //wordArray = createWordList(wordArray,
strbase + remainingchars.charAt(j), remainingchars.substring(0, j) +
remainingchars.substring(j+1, remainingchars.length)); //recursive
call

That's how it's done in Javascript.. I just can't convert it to ColdFusion..




On Feb 13, 2008 6:44 PM, Mark Mandel <[EMAIL PROTECTED]> wrote:
> What have you got so far?
>
> Mark
>
> On Feb 14, 2008 10:58 AM, Greg Morphis <[EMAIL PROTECTED]> wrote:
> > yes, I know that and it's that part that I need help with which is why
> > I posted here.
> > Thanks
> >
> > On Feb 13, 2008 5:34 PM, Mark Mandel <[EMAIL PROTECTED]> wrote:
> > > Recursion is your friend ;o)
> > >
> > > Mark
> > >
> > >
> > > On Feb 14, 2008 9:57 AM, Greg Morphis <[EMAIL PROTECTED]> wrote:
> > > > Given a string, e.g. "ABCD"
> > > >
> > > > I need to come up with all combinations of letters
> > > > eg
> > > > ABCD
> > > > ABDC
> > > > ACBD
> > > > ACDB
> > > > ....
> > > >
> > > > And exlude strings like 'AAAA', 'AAAB' unless you pass a string with
> > > > duplicate characters
> > > > If I pass the string "AAAB" then it'd return:
> > > > AAAB
> > > > AABA
> > > > ABAA
> > > > BAAA
> > > >
> > > >
> > >
> > >
> >
> >
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:298940
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to