RE: Max value of 3 variables

2005-04-15 Thread Michael T. Tangorre
 From: G [mailto:[EMAIL PROTECTED] 
 Got three variables passed into me, all are decimal values. 
 What is the quickest and most elegant way of determining 
 which of the variables holds the largest value?

Max(Max(number1, number2),number3)

Mike




~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:203026
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Max value of 3 variables

2005-04-15 Thread G
ty MT.

 From: G [mailto:[EMAIL PROTECTED]
 Got three variables passed into me, all are decimal values.
 What is the quickest and most elegant way of determining
 which of the variables holds the largest value?

 Max(Max(number1, number2),number3)

 Mike




 

~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:203027
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Max value of 3 variables

2005-04-15 Thread Ewok
Max() should do it if you're not going to eventually have more values.

Think it can only take 2 values so nest them like max(max(no1, no2), no3)

If its going to be more... just loop them, if the currnent value is larger
than the previous, set it to the max...

cfset max = 0 

cfloop list=#numbers# index=i
  cfif i gt max
cfset max = i
  /cfif
/cfloop

-Original Message-
From: G [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 15, 2005 8:58 AM
To: CF-Talk
Subject: Max value of 3 variables

Got three variables passed into me, all are decimal values. What is the
quickest and most elegant way of determining which of the variables holds
the largest value?

TIA,

BG




~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:203028
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Max value of 3 variables

2005-04-15 Thread Calvin Ward
For flexibility, how about this: ListFirst(ListSort(numbers,'numeric'))

-Calvin

-Original Message-
From: Ewok [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 15, 2005 9:10 AM
To: CF-Talk
Subject: RE: Max value of 3 variables

Max() should do it if you're not going to eventually have more values.

Think it can only take 2 values so nest them like max(max(no1, no2), no3)

If its going to be more... just loop them, if the currnent value is larger
than the previous, set it to the max...

cfset max = 0 

cfloop list=#numbers# index=i
  cfif i gt max
cfset max = i
  /cfif
/cfloop

-Original Message-
From: G [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 15, 2005 8:58 AM
To: CF-Talk
Subject: Max value of 3 variables

Got three variables passed into me, all are decimal values. What is the
quickest and most elegant way of determining which of the variables holds
the largest value?

TIA,

BG






~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:203032
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Max value of 3 variables

2005-04-15 Thread Paul
Or #arrayMax(listToArray(numbers))#

-Original Message-
From: Calvin Ward [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 15, 2005 7:18 AM
To: CF-Talk
Subject: RE: Max value of 3 variables

For flexibility, how about this: ListFirst(ListSort(numbers,'numeric'))

-Calvin

-Original Message-
From: Ewok [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 15, 2005 9:10 AM
To: CF-Talk
Subject: RE: Max value of 3 variables

Max() should do it if you're not going to eventually have more values.

Think it can only take 2 values so nest them like max(max(no1, no2), no3)

If its going to be more... just loop them, if the currnent value is larger
than the previous, set it to the max...

cfset max = 0 

cfloop list=#numbers# index=i
  cfif i gt max
cfset max = i
  /cfif
/cfloop

-Original Message-
From: G [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 15, 2005 8:58 AM
To: CF-Talk
Subject: Max value of 3 variables

Got three variables passed into me, all are decimal values. What is the
quickest and most elegant way of determining which of the variables holds
the largest value?

TIA,

BG








~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:203053
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Max value of 3 variables

2005-04-15 Thread Rick Faircloth
 Or #arrayMax(listToArray(numbers))#

 For flexibility, how about this: ListFirst(ListSort(numbers,'numeric'))

And how, exactly, would these assist in obtaining
the top value of 3 numbers?

Does arrayMax put the maximum value first in the array?

I guess ListFirst(ListSort(... would put the maximum value first in the
list?

Rick


 -Original Message-
 From: Paul [mailto:[EMAIL PROTECTED]
 Sent: Friday, April 15, 2005 10:44 AM
 To: CF-Talk
 Subject: RE: Max value of 3 variables


 Or #arrayMax(listToArray(numbers))#

 -Original Message-
 From: Calvin Ward [mailto:[EMAIL PROTECTED]
 Sent: Friday, April 15, 2005 7:18 AM
 To: CF-Talk
 Subject: RE: Max value of 3 variables

 For flexibility, how about this: ListFirst(ListSort(numbers,'numeric'))

 -Calvin

 -Original Message-
 From: Ewok [mailto:[EMAIL PROTECTED]
 Sent: Friday, April 15, 2005 9:10 AM
 To: CF-Talk
 Subject: RE: Max value of 3 variables

 Max() should do it if you're not going to eventually have more values.

 Think it can only take 2 values so nest them like max(max(no1, no2), no3)

 If its going to be more... just loop them, if the currnent value is larger
 than the previous, set it to the max...

 cfset max = 0 

 cfloop list=#numbers# index=i
   cfif i gt max
 cfset max = i
   /cfif
 /cfloop

 -Original Message-
 From: G [mailto:[EMAIL PROTECTED]
 Sent: Friday, April 15, 2005 8:58 AM
 To: CF-Talk
 Subject: Max value of 3 variables

 Got three variables passed into me, all are decimal values. What is the
 quickest and most elegant way of determining which of the variables holds
 the largest value?

 TIA,

 BG








 

~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:203066
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Max value of 3 variables

2005-04-15 Thread Calvin Ward
It should, but you'll probably actually have to add the desc attribute at
the end of my suggestion.

- Calvin

-Original Message-
From: Rick Faircloth [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 15, 2005 11:08 AM
To: CF-Talk
Subject: RE: Max value of 3 variables

 Or #arrayMax(listToArray(numbers))#

 For flexibility, how about this: ListFirst(ListSort(numbers,'numeric'))

And how, exactly, would these assist in obtaining
the top value of 3 numbers?

Does arrayMax put the maximum value first in the array?

I guess ListFirst(ListSort(... would put the maximum value first in the
list?

Rick


 -Original Message-
 From: Paul [mailto:[EMAIL PROTECTED]
 Sent: Friday, April 15, 2005 10:44 AM
 To: CF-Talk
 Subject: RE: Max value of 3 variables


 Or #arrayMax(listToArray(numbers))#

 -Original Message-
 From: Calvin Ward [mailto:[EMAIL PROTECTED]
 Sent: Friday, April 15, 2005 7:18 AM
 To: CF-Talk
 Subject: RE: Max value of 3 variables

 For flexibility, how about this: ListFirst(ListSort(numbers,'numeric'))

 -Calvin

 -Original Message-
 From: Ewok [mailto:[EMAIL PROTECTED]
 Sent: Friday, April 15, 2005 9:10 AM
 To: CF-Talk
 Subject: RE: Max value of 3 variables

 Max() should do it if you're not going to eventually have more values.

 Think it can only take 2 values so nest them like max(max(no1, no2), no3)

 If its going to be more... just loop them, if the currnent value is larger
 than the previous, set it to the max...

 cfset max = 0 

 cfloop list=#numbers# index=i
   cfif i gt max
 cfset max = i
   /cfif
 /cfloop

 -Original Message-
 From: G [mailto:[EMAIL PROTECTED]
 Sent: Friday, April 15, 2005 8:58 AM
 To: CF-Talk
 Subject: Max value of 3 variables

 Got three variables passed into me, all are decimal values. What is the
 quickest and most elegant way of determining which of the variables holds
 the largest value?

 TIA,

 BG








 



~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:203068
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Max value of 3 variables

2005-04-15 Thread Keith Gaughan
Calvin Ward wrote:

 For flexibility, how about this: ListFirst(ListSort(numbers,'numeric'))

If we were talking about a lower-level language, I'd warn against that
way of doing it. On average, ListSort() takes O(nlogn) to sort a list,
whereas scanning the list with cfloop as below will be done in O(n)
time, which is faster. The only advantage that using ListSort() has is
that it's precompiled into Java.

Come to think of it, a linear scan will still be faster regardless,
unless you're dealing with CF5 or below.

The best and safest way to scan an unsorted list for the maximum number
would be:

!---
 Using the first element as our default max ensures that if the
 list contains only negative numbers, it will still work properly.
 This is my one improvement over Ewok's method.
---
cfset max = ListFirst(numbers)
cfloop index=i list=#numbers#
 cfif i gt max
 cfset max = i
 /cfif
/cfloop

K.

~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:203069
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Max value of 3 variables

2005-04-15 Thread Justin D. Scott
 ListFirst(ListSort(numbers,'numeric'))

 It should, but you'll probably actually have to add the
 desc attribute at the end of my suggestion.

Or use listLast() instead.


-Justin


~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:203071
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Max value of 3 variables

2005-04-15 Thread Keith Gaughan
Rick Faircloth wrote:

Or #arrayMax(listToArray(numbers))#
 
For flexibility, how about this: ListFirst(ListSort(numbers,'numeric'))
 
 
 And how, exactly, would these assist in obtaining
 the top value of 3 numbers?
 
 Does arrayMax put the maximum value first in the array?

No, it searches the array and returns the maximum value in it.

 I guess ListFirst(ListSort(... would put the maximum value first in the
 list?

No, it doesn't touch the list except to sort it, and then return the
first value in the list.

If it's just three numbers, then Max(Max(a, b), c) is fine, but as the 
saying goes, two is an impossible number[1]: it's worth generalising
this to cope with any number of values, which is what everybody was
doing.

K.

[1] http://c2.com/cgi/wiki?TwoIsAnImpossibleNumber

~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:203072
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Max value of 3 variables

2005-04-15 Thread Paul
arrayMax returns the largest numeric value in an array.

http://livedocs.macromedia.com/coldfusion/7/htmldocs/0388.htm

-Original Message-
From: Rick Faircloth [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 15, 2005 9:08 AM
To: CF-Talk
Subject: RE: Max value of 3 variables

 Or #arrayMax(listToArray(numbers))#

 For flexibility, how about this: ListFirst(ListSort(numbers,'numeric'))

And how, exactly, would these assist in obtaining
the top value of 3 numbers?

Does arrayMax put the maximum value first in the array?

I guess ListFirst(ListSort(... would put the maximum value first in the
list?

Rick


 -Original Message-
 From: Paul [mailto:[EMAIL PROTECTED]
 Sent: Friday, April 15, 2005 10:44 AM
 To: CF-Talk
 Subject: RE: Max value of 3 variables


 Or #arrayMax(listToArray(numbers))#

 -Original Message-
 From: Calvin Ward [mailto:[EMAIL PROTECTED]
 Sent: Friday, April 15, 2005 7:18 AM
 To: CF-Talk
 Subject: RE: Max value of 3 variables

 For flexibility, how about this: ListFirst(ListSort(numbers,'numeric'))

 -Calvin

 -Original Message-
 From: Ewok [mailto:[EMAIL PROTECTED]
 Sent: Friday, April 15, 2005 9:10 AM
 To: CF-Talk
 Subject: RE: Max value of 3 variables

 Max() should do it if you're not going to eventually have more values.

 Think it can only take 2 values so nest them like max(max(no1, no2), no3)

 If its going to be more... just loop them, if the currnent value is larger
 than the previous, set it to the max...

 cfset max = 0 

 cfloop list=#numbers# index=i
   cfif i gt max
 cfset max = i
   /cfif
 /cfloop

 -Original Message-
 From: G [mailto:[EMAIL PROTECTED]
 Sent: Friday, April 15, 2005 8:58 AM
 To: CF-Talk
 Subject: Max value of 3 variables

 Got three variables passed into me, all are decimal values. What is the
 quickest and most elegant way of determining which of the variables holds
 the largest value?

 TIA,

 BG








 



~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:203081
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Max value of 3 variables

2005-04-15 Thread Rick Faircloth
Gotcha...thanks...

Rick


 -Original Message-
 From: Keith Gaughan [mailto:[EMAIL PROTECTED]
 Sent: Friday, April 15, 2005 11:36 AM
 To: CF-Talk
 Subject: Re: Max value of 3 variables
 
 
 Rick Faircloth wrote:
 
 Or #arrayMax(listToArray(numbers))#
  
 For flexibility, how about this: ListFirst(ListSort(numbers,'numeric'))
  
  
  And how, exactly, would these assist in obtaining
  the top value of 3 numbers?
  
  Does arrayMax put the maximum value first in the array?
 
 No, it searches the array and returns the maximum value in it.
 
  I guess ListFirst(ListSort(... would put the maximum value 
 first in the
  list?
 
 No, it doesn't touch the list except to sort it, and then return the
 first value in the list.
 
 If it's just three numbers, then Max(Max(a, b), c) is fine, but as the 
 saying goes, two is an impossible number[1]: it's worth generalising
 this to cope with any number of values, which is what everybody was
 doing.
 
 K.
 
 [1] http://c2.com/cgi/wiki?TwoIsAnImpossibleNumber
 
 

~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:203080
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54