the replace idea won't work.  it will replace all 'a' with 'z', then 
replace all 'z' with 't'

this leads to all 'a' being replaced with 't', not with all 'a' being 
replaced with 't'.

without instantiating java...

<cfset newDNA = "">
<cfset iTo = len(dna)>
<cfloop from="1" to="#iTo#" index="i">
 <cfset letter = MID(dna,i,1)>
 <cfswitch expression="#letter#">
    <cfcase value="C"><cfset newLetter = "G"></cfcase>
    <cfcase value="G"><cfset newLetter = "C"></cfcase>
    <cfcase value="A"><cfset newLetter = "T"></cfcase>
    <cfcase value="T"><cfset newLetter = "A"></cfcase>
    <cfdefaultcase><cfset newLetter = letter></cfdefaultcase>
  </cfswitch>
  <cfset newDNA = newDNA & newLetter>
</cfloop>

Probably not the most efficient, but it should get you there.
-Jeff

Barney Boisvert wrote:

>I didn't say it was perfect. ;)  The replace stuff is a lot better, most 
>likely.
>
>I used a StringBuffer because string manipulation in Java is quite
>slow, and by using a buffer I'd circumvent the issue almost
>completely.
>
>cheers,
>barneyb
>
>On 6/14/05, Matthew Small <[EMAIL PROTECTED]> wrote:
>  
>
>>That seems like a lot of work.  Why instantiate java?
>>
>><cfscript>
>>        dna = "actg";
>>        newdna = dna;
>>        newdna = replace(newdna,"a","z");
>>        newdna = replace(newdna,"t","a");
>>        newdna = replace(newdna,"z","t");
>>        newdna = replace(newdna,"c","z");
>>        newdna = replace(newdna,"g","c");
>>        newdna = replace(newdna,"z","g");
>></cfscript>
>>    
>>
>
>
>  
>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:209464
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to