Skip to main content
Inspiring
June 26, 2012
Answered

list question

  • June 26, 2012
  • 1 reply
  • 594 views

I have a simple list:  1, 3, 6, 7, 11, 13, 16, 21

I want to count the list where the numbers are greater than 8. So my end result for this list should be "4" (11, 13, 16, 21).

I've read through all the list functions and nothing seems to fit. How do I evaluate the items in a list to see fi they greater than 8 then count only those items?

Thanks

This topic has been closed for replies.
Correct answer Adam Cameron.

Initialise a new list as an empty string.

Loop over the first list with CFLOOP:

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-71a7.html

Check each element for your condition.

If it meets the condition, append it to the new list.

After the loop, the new list will have the values you want.

There is no more expedient way of doing it than that, really.

--

Adam

1 reply

Adam Cameron.Correct answer
Inspiring
June 26, 2012

Initialise a new list as an empty string.

Loop over the first list with CFLOOP:

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-71a7.html

Check each element for your condition.

If it meets the condition, append it to the new list.

After the loop, the new list will have the values you want.

There is no more expedient way of doing it than that, really.

--

Adam

wam4Author
Inspiring
June 26, 2012

Thanks that worked. i was hoping Coldfusion had something the evaluated within the list but that works.

Inspiring
June 26, 2012

Well: if yer on CF10, there's listFilter() which might work for you:

http://help.adobe.com/en_US/ColdFusion/10.0/CFMLRef/WSf23b27ebc7b554b61273c87513585aed2a9-8000.html

It's probably not as expedient as just looping over the list though.

--

Adam