<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
<br>Obviously, on the lists:foldl you don't need to do ++[2.1] at the end ;)<div><br></div><div><br><div><div id="SkyDrivePlaceholder"></div><hr id="stopSpelling">From: mattevans123@hotmail.com<br>To: thomas.burdick@gmail.com; erlang-questions@erlang.org<br>Date: Mon, 27 Feb 2012 12:26:41 -0500<br>Subject: Re: [erlang-questions] Inf, NaN, and -Inf<br><br>
<meta http-equiv="Content-Type" content="text/html; charset=unicode">
<meta name="Generator" content="Microsoft SafeHTML">
<style>
.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:10pt;font-family:Tahoma;}
</style>
<div dir="ltr">
<div><font face="'Lucida Console'"><br></font></div><div><font face="'Lucida Console'">You can use lists:sort/1</font></div><div style="font-family:'Lucida Console'"><br></div><div>> List = [7.1,2.2,1.1,5.7,2].</div><div>[7.1,2.2,1.1,5.7,2]</div><div>2> Sorted = lists:sort(List).</div><div>[1.1,2,2.2,5.7,7.1]</div><div>3> hd(Sorted).</div><div>1.1</div><div><div>4> lists:last(Sorted).</div><div>7.1</div></div><div><br></div><div>Or using lists:fold/3:</div><div><br></div><div><div>5> lists:foldl(fun(Val,{Min,Max}) -> {erlang:min(Val,Min),erlang:max(Val,Max)} end, {erlang:hd(List),erlang:hd(List)}, List++[2.1]). </div><div>{1.1,7.1}</div></div><div><br></div><div>Matt</div>----------------------------------------<br>> Date: Mon, 27 Feb 2012 11:07:53 -0600<br>> From: thomas.burdick@gmail.com<br>> To: erlang-questions@erlang.org<br>> Subject: [erlang-questions] Inf, NaN, and -Inf<br>><br>> So in python and C to find the biggest and smallest number in a list<br>> of floating point numbers I'd do something like a lists:foldl and<br>> simply give it<br>><br>> inf and -inf respectively as the values to compare against, or better<br>> yet use some built in defines or variables defining what the min and<br>> max values for a particular number type are.<br>><br>> Is there some sane way to do this in erlang? Is there a way to get the<br>> floating point values inf and -inf in erlang or the maximal and<br>> minimal values for integers and floats in erlang? I didn't see it in<br>> my hunt around the documentation perhaps I just missed it.<br>><br>> Thanks!<br>><br>> Tom<br>> _______________________________________________<br>> erlang-questions mailing list<br>> erlang-questions@erlang.org<br>> http://erlang.org/mailman/listinfo/erlang-questions<br> </div>
<br>_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions</div></div> </div></body>
</html>