Re: Max/Min values in an associative array

2014-08-15 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Aug 15, 2014 at 04:51:59PM +, monarch_dodra via Digitalmars-d-learn wrote: > On Wednesday, 6 August 2014 at 18:07:08 UTC, H. S. Teoh via > Digitalmars-d-learn wrote: > > > > import std.algorithm : reduce, max, min; > > > > auto highest = reduce!((a,b) => max(a,b))(-double.max,

Re: Max/Min values in an associative array

2014-08-15 Thread monarch_dodra via Digitalmars-d-learn
On Wednesday, 6 August 2014 at 18:07:08 UTC, H. S. Teoh via Digitalmars-d-learn wrote: import std.algorithm : reduce, max, min; auto highest = reduce!((a,b) => max(a,b))(-double.max, bids.byValue()); auto lowest = reduce!((a,b) => min(a,b))(double.max, bids.byValue()); T Take a

Re: Max/Min values in an associative array

2014-08-14 Thread bearophile via Digitalmars-d-learn
TJB: I am trying to find the max and min values in an associative array. Say I have: double[char] bids; bid['A'] = 37.50; bid['B'] = 38.11; bid['C'] = 36.12; How can I find the max and min values. I am thinking that I need to use max and min functions from std.algorithm, but not sure how to

Re: Max/Min values in an associative array

2014-08-06 Thread TJB via Digitalmars-d-learn
Justin, That's it! Perfect - thanks!! TJB Do you just need the min and max values or do you also need the keys of those values? If the former, here's a paste: http://dpaste.dzfl.pl/0bbf31278a25

Re: Max/Min values in an associative array

2014-08-06 Thread Martijn Pot via Digitalmars-d-learn
On Wednesday, 6 August 2014 at 17:57:55 UTC, TJB wrote: I am trying to find the max and min values in an associative array. Say I have: double[char] bids; bid['A'] = 37.50; bid['B'] = 38.11; bid['C'] = 36.12; How can I find the max and min values. I am thinking that I need to use max and min

Re: Max/Min values in an associative array

2014-08-06 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Aug 06, 2014 at 05:57:54PM +, TJB via Digitalmars-d-learn wrote: > I am trying to find the max and min values in an associative array. Say I > have: > > double[char] bids; > bid['A'] = 37.50; > bid['B'] = 38.11; > bid['C'] = 36.12; > > How can I find the max and min values. I am think

Re: Max/Min values in an associative array

2014-08-06 Thread Justin Whear via Digitalmars-d-learn
On Wed, 06 Aug 2014 17:57:54 +, TJB wrote: > I am trying to find the max and min values in an associative array. Say > I have: > > double[char] bids; > bid['A'] = 37.50; > bid['B'] = 38.11; > bid['C'] = 36.12; > > How can I find the max and min values. I am thinking that I need to use > max

Max/Min values in an associative array

2014-08-06 Thread TJB via Digitalmars-d-learn
I am trying to find the max and min values in an associative array. Say I have: double[char] bids; bid['A'] = 37.50; bid['B'] = 38.11; bid['C'] = 36.12; How can I find the max and min values. I am thinking that I need to use max and min functions from std.algorithm, but not sure how to. Tha