def lowercase(string)
string.gsub(/([A-Z])/) {|c| (c[0]+32).chr}
end
regular expressions, closures....how much more convoluted can you get :)
On Aug 9, 2010, at 12:17 PM, Rick Root wrote:
>
> 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=11831
>
> 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:324576
Subscription: http://www.houseoffusion.com/groups/cf-community/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-community/unsubscribe.cfm