Haha. Now THAT is a nice waste of space. I like how you test for the
existence of the letter before you replace it.

This actually makes me want to run speed tests on what would be faster:

1. testing for existence of lowercase letter - replacing lowercase with
uppercase using replace.
2. not testing and just replacing the lowercase with the uppercase using
replace.
3. just using replacenocase and replacing all letters with the uppercase
equiv.

I bet if I showed this code to my boss he'd be like "whoa, that's deep."




On Wed, Aug 11, 2010 at 11:18 AM, Jacob <ja...@excaliburfilms.com> wrote:

>
> Not a function, but..
>
> <cfset tempString = "WhAtEvERStriNG">
>
> <cfif find("A", tempString) gt 0>
>        <cfset tempString = replace(tempString, "A", "a", "ALL")>
> </cfif>
> <cfif find("B", tempString) gt 0>
>        <cfset tempString = replace(tempString, "B", "b", "ALL")>
> </cfif>
> <cfif find("C", tempString) gt 0>
>        <cfset tempString = replace(tempString, "C", "c", "ALL")>
> </cfif>
> <cfif find("D", tempString) gt 0>
>        <cfset tempString = replace(tempString, "D", "d", "ALL")>
> </cfif>
> <cfif find("E", tempString) gt 0>
>        <cfset tempString = replace(tempString, "E", "e", "ALL")>
> </cfif>
> <cfif find("F", tempString) gt 0>
>        <cfset tempString = replace(tempString, "F", "f", "ALL")>
> </cfif>
> <cfif find("G", tempString) gt 0>
>        <cfset tempString = replace(tempString, "G", "g", "ALL")>
> </cfif>
> <cfif find("H", tempString) gt 0>
>        <cfset tempString = replace(tempString, "H", "h", "ALL")>
> </cfif>
> <cfif find("I", tempString) gt 0>
>        <cfset tempString = replace(tempString, "I", "i", "ALL")>
> </cfif>
> <cfif find("J", tempString) gt 0>
>        <cfset tempString = replace(tempString, "J", "j", "ALL")>
> </cfif>
> <cfif find("K", tempString) gt 0>
>        <cfset tempString = replace(tempString, "K", "k", "ALL")>
> </cfif>
> <cfif find("L", tempString) gt 0>
>        <cfset tempString = replace(tempString, "L", "l", "ALL")>
> </cfif>
> <cfif find("M", tempString) gt 0>
>        <cfset tempString = replace(tempString, "M", "m", "ALL")>
> </cfif>
> <cfif find("N", tempString) gt 0>
>        <cfset tempString = replace(tempString, "N", "n", "ALL")>
> </cfif>
> <cfif find("O", tempString) gt 0>
>        <cfset tempString = replace(tempString, "O", "o", "ALL")>
> </cfif>
> <cfif find("P", tempString) gt 0>
>        <cfset tempString = replace(tempString, "P", "p", "ALL")>
> </cfif>
> <cfif find("Q", tempString) gt 0>
>        <cfset tempString = replace(tempString, "Q", "q", "ALL")>
> </cfif>
> <cfif find("R", tempString) gt 0>
>        <cfset tempString = replace(tempString, "R", "r", "ALL")>
> </cfif>
> <cfif find("S", tempString) gt 0>
>        <cfset tempString = replace(tempString, "S", "s", "ALL")>
> </cfif>
> <cfif find("T", tempString) gt 0>
>        <cfset tempString = replace(tempString, "T", "t", "ALL")>
> </cfif>
> <cfif find("U", tempString) gt 0>
>        <cfset tempString = replace(tempString, "U", "u", "ALL")>
> </cfif>
> <cfif find("V", tempString) gt 0>
>        <cfset tempString = replace(tempString, "V", "v", "ALL")>
> </cfif>
> <cfif find("W", tempString) gt 0>
>        <cfset tempString = replace(tempString, "W", "w", "ALL")>
> </cfif>
> <cfif find("X", tempString) gt 0>
>        <cfset tempString = replace(tempString, "X", "x", "ALL")>
> </cfif>
> <cfif find("Y", tempString) gt 0>
>        <cfset tempString = replace(tempString, "Y", "y", "ALL")>
> </cfif>
> <cfif find("Z", tempString) gt 0>
>        <cfset tempString = replace(tempString, "Z", "z", "ALL")>
> </cfif>
>
> <cfoutput>#tempString#</cfoutput>
>
> -----Original Message-----
> From: Rick Root [mailto:rick.r...@gmail.com]
> Sent: Monday, August 09, 2010 10:18 AM
> To: cf-community
> Subject: Dysfunctional contest
>
>
> Write a function to convert a string to lower case
>
> Do not use lcase()
>
> Example:
>
>
> <cffunction name="toLowerCase" access="public" output="false"
> returnType="string">
>        <cfargument name="src" type="string" required="yes">
>
>        <cfset var result = "">
>        <cfloop from="1" to="#len(arguments.src)#" step="1" index="pos">
>                <cfset thisChar = mid(arguments.src,pos,1)>
>                <cfif asc(thisChar) gte 65 and asc(thisChar) lte 90>
>                        <cfset result &= chr(asc(thisChar)+32)>
>                <cfelse>
>                        <cfset result &= thisChar>
>                </cfif>
>        </cfloop>
>        <cfreturn result />
> </cffunction>
>
> PRIZE:  Respect for writing incredibly convoluted code, or lack of respect
> for having time to waste on such inanity
>
> Alternatively, write your own convoluted function for something similarly
> simple.
>
> This thread was inspired by the following article:
>
>
> http://www.easycfm.com/coldfusion/forums/printthread.cfm?Forum=12&Topic=1183
> 1
>
> Rick
>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-community/message.cfm/messageid:324654
Subscription: http://www.houseoffusion.com/groups/cf-community/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-community/unsubscribe.cfm

Reply via email to