|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
comma delimited list of integer
Hello to everyone!
How do i get the sum of a comma delimited list of integer values? Tnx. |
|
#2
|
|||
|
|||
|
You'll have to loop through the list & add them all up manually.
-D |
|
#3
|
|||
|
|||
|
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#4
|
|||
|
|||
|
No need to loop
try this, it converts the List to an Array, and then gets the sum.
<cfset someList="1,2,3,4,5"> <cfset totalSum=ArraySum(ListToArray(variables.someList))> <cfoutput> #variables.totalSum# </cfoutput> |
|
#5
|
|||
|
|||
|
A nice alternate approach! I'd be interested to see if the overhead of transforming a list into an array is more or less than the overhead of looping over the list...but unless the list is huge the difference would probably be neglegable.
|
|
#6
|
|||
|
|||
|
no wrong ways
This thread reminds me of an article I came across a while back on Fusion Authority
http://www.fusionauthority.com/Arti.../ArticleID=4128 It just goes to show that everyone may have a different approach to solve the same problem. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > comma delimited list of integer |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|