On 10/3/07, Zaphod Beeblebrox <[EMAIL PROTECTED]> wrote: > # our test input > input = 25 > > # change the list to an array > nums = "32,48,64,72,144,160,200,288,320,400,512,576,640,720,800".split(",") > > # find all the numbers which would be smaller > target = nums.find_all {|num| input >= num.to_i }
Well, with my Closures for ColdFusion library and the Collection class I added to it on the flight back from MAX, that would look like: nums = listToArray("32,48,64,72,144,160,200,288,320,400,512,576,640,720,800"); target = createObject("component","Collection").init(nums).select( "num", "25 gte num" ); or, if you wanted to isolate input = 25, use the Closure factory: cf = createObject("component","ClosureFactory"); findGTE = cf.new( "threshold gte num", "num" ); input = 25; target = createObject("component","Collection").init(nums).select( findGTE.bind(threshold=input) ); Whilst I accept that it isn't quite as clean as the Ruby syntax, it certainly is possible with ColdFusion... The Collection class is modeled after Smalltalk... Want to add up all the elements in a collection of numbers? total = someCollection.inject( 0, "sum,x", "sum + x" ); Count how many four letter words are in a collection of words? num = wordCollection.count( "w", "len(w) eq 4" ); The closure factory (which is also used by the collection class) caches the generated code so it gives good performance. I'll be blogging about the new Collection class soon - I just need to finish the documentation. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ "If you're not annoying somebody, you're not really alive." -- Margaret Atwood ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| ColdFusion is delivering applications solutions at at top companies around the world in government. Find out how and where now http://www.adobe.com/cfusion/showcase/index.cfm?event=finder&productID=1522&loc=en_us Archive: http://www.houseoffusion.com/groups/CF-Community/message.cfm/messageid:243622 Subscription: http://www.houseoffusion.com/groups/CF-Community/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.5