www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - "min" and "max"

reply pascal111 <judas.the.messiah.111 gmail.com> writes:
"min" and "max" in "std.algorithm" can be used with single values 
to pick up the min and max values, but it didn't mention how they 
can be used with ranges in the documentation:

https://dlang.org/phobos/std_algorithm_comparison.html#.min
Aug 09 2022
parent reply Paul Backus <snarwin gmail.com> writes:
On Tuesday, 9 August 2022 at 23:35:23 UTC, pascal111 wrote:
 "min" and "max" in "std.algorithm" can be used with single 
 values to pick up the min and max values, but it didn't mention 
 how they can be used with ranges in the documentation:

 https://dlang.org/phobos/std_algorithm_comparison.html#.min
The docs do mention `minElement` and `maxElement` (the range versions) under the "See Also" heading, but you're right that it's not super clear *why* they're mentioned.
Aug 09 2022
parent reply pascal111 <judas.the.messiah.111 gmail.com> writes:
On Tuesday, 9 August 2022 at 23:56:53 UTC, Paul Backus wrote:
 On Tuesday, 9 August 2022 at 23:35:23 UTC, pascal111 wrote:
 "min" and "max" in "std.algorithm" can be used with single 
 values to pick up the min and max values, but it didn't 
 mention how they can be used with ranges in the documentation:

 https://dlang.org/phobos/std_algorithm_comparison.html#.min
The docs do mention `minElement` and `maxElement` (the range versions) under the "See Also" heading, but you're right that it's not super clear *why* they're mentioned.
They said " If at least one of the arguments is NaN, the result is an unspecified value. See std.algorithm.searching.minElement for examples on how to cope with NaNs.", as a beginner how can I guess what "NaNs" means or if it refers to ranges?!
Aug 09 2022
next sibling parent jfondren <julian.fondren gmail.com> writes:
On Wednesday, 10 August 2022 at 00:03:37 UTC, pascal111 wrote:
 On Tuesday, 9 August 2022 at 23:56:53 UTC, Paul Backus wrote:
 On Tuesday, 9 August 2022 at 23:35:23 UTC, pascal111 wrote:
 "min" and "max" in "std.algorithm" can be used with single 
 values to pick up the min and max values, but it didn't 
 mention how they can be used with ranges in the documentation:

 https://dlang.org/phobos/std_algorithm_comparison.html#.min
The docs do mention `minElement` and `maxElement` (the range versions) under the "See Also" heading, but you're right that it's not super clear *why* they're mentioned.
They said " If at least one of the arguments is NaN, the result is an unspecified value. See std.algorithm.searching.minElement for examples on how to cope with NaNs.", as a beginner how can I guess what "NaNs" means or if it refers to ranges?!
When something unexplained, it might be because it's assumed to be general knowledge. So you can search for that term on a web search engine. The good ones immediately come up with the wikipedia entry for the computing term. Google has a definition and a bunch of ads but, below these, the same wikipedia entry.
Aug 09 2022
prev sibling parent reply =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 8/9/22 17:03, pascal111 wrote:

 They said " If at least one of the arguments is NaN, the result is an
 unspecified value.
That's called "unorderedness": http://ddili.org/ders/d.en/floating_point.html#ix_floating_point.unordered
 as a beginner how can I guess what "NaNs"
 means or if it refers to ranges?!
You can use the index: ;) http://ddili.org/ders/d.en/ix.html There are a couple of entries for 'nan' there. Ali
Aug 09 2022
parent pascal111 <judas.the.messiah.111 gmail.com> writes:
On Wednesday, 10 August 2022 at 00:32:02 UTC, Ali Çehreli wrote:
 On 8/9/22 17:03, pascal111 wrote:

 as a beginner how can I guess what "NaNs"
 means or if it refers to ranges?!
You can use the index: ;) http://ddili.org/ders/d.en/ix.html There are a couple of entries for 'nan' there. Ali
You mentioned it twice! I guess it's your right now to blame me :)
Aug 09 2022