max function only allows two arguments?

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default max function only allows two arguments?

    I need a function that will return the highest value from a set of numerical
    variables. The max function only works with two numbers.

    e.g. <cfif #crystallization_avg# IS max(#crystallization_avg#,
    #specification#, #implementation#)>

    Any ideas?

    Thanks,

    Paul

    pglavin Guest

  2. Similar Questions and Discussions

    1. named arguments to XS function?
      hi there, i'm wondering if it's possible to pass named arguments to an XS function like so: $myObj = Package::Bla->new(arg1=>"hello",...
    2. [PHP-DEV] named function arguments
      Sebastian Bergmann wrote: So, how do you think that isn't known to the original poster as he even explicitely states that he wants to remove the...
    3. [PHP-DEV] named function arguments (was: Proposal: Dangling comma in function
      Christian Schneider wrote: Named parameters - i think is very good idea. I know i would use them. I'm really not sure about the correct...
    4. Function arguments
      Hi Group, I have a question on overloaded function. What is the best way to pass the arguments so it is easy to maintain in future if function...
    5. [PHP] Function arguments
      Hello, If you are worried about this issue your best option is to switch to an object oriented approach. all the best Hardik Doshi wrote:
  3. #2

    Default Re: max function only allows two arguments?

    Put them in a list or array and sort them.
    jdeline Guest

  4. #3

    Default Re: max function only allows two arguments?

    If you have a list (or set) of numerical values named mylist, you can get the maximum value like this:

    ListGetAt(ListSort(mylist, "Numeric", "desc"),1)

    -Paul

    dempster Guest

  5. #4

    Default Re: max function only allows two arguments?

    pglavin,

    If you're using a list, take a look at the [url]http://cflib.org/udf.cfm?ID=806[/url]
    function at cflib.org. It's very easy to use.

    The basic concept is that you take a list of values, convert the list to an
    array and use ArrayMax() to get the maximum value.

    <cfset listOfValues = "12,14.3,122.6,8,19.26,4">
    <cfset maxValue = ArrayMax(ListToArray(listOfValues))>
    <cfoutput>#MaxValue#</cfoutput>

    As an alternative you could easily create your own UDF that accepts a variable
    number of parameters (instead of a single list of values).


    mxstu Guest

  6. #5

    Default Re: max function only allows two arguments?

    Many thanks,

    Paul
    pglavin Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139