<div dir="ltr"><div>Hi there to you all!<br><br></div><div>I've been reading through the first chapter of "Learn You a Haskell" and I'd like to ask the community a few questions.<br><br></div><div>Any help would be appreciated...<br>
<br></div><div>-- ----------  ----------  ----------  ----------  ----------  <br><br></div><div>All the standard Prelude functions that throw out an error when fed the []!<br><br></div><div>head<br></div><div>maximum<br>
</div><div>...<br><br></div><div>Are there safe versions anywhere, or do we have to define them ourselves?<br></div><div><br>-- ----------  ----------  ----------  ----------  ----------  <br><br>This one is really important!<br>
<br></div><div>I understand that for the definition of product to work as it is:<br>  product [] must be equal to 1<br></div><div><br></div><div>But what if we want to add a product to something else???<br></div><div>Shouldn't the result be Nothing?<br>
</div><div>(I guess we would have to guard against this! But we must guard against the parameter of product being the empty list, anyway. Otherwise we risk adding 1 when there is nothing do multiply)<br><br>(The same question arises with the functions and and or, and their boolean results, I think! Right?)<br>
<br>-- ----------  ----------  ----------  ----------  ----------  <br><br>-- ----------  Start Quote<br> <br>Names can't be enumerated. What comes after "John"? I don't know.<br> <br>--  ---------- End Quote<br>
<br></div><div>"a" to "z" then "aa" to "zz" then "aaa" to "zzz" and so on! Is it to difficult or impossible to create a function that enumerates all possible strings?<br>
<br>-- ----------  ----------  ----------  ----------  ----------  <br><br>-- ----------  Start Quote<br><br>To make a list with all the numbers from 20 to 1, you can't just do <span class="">[20..1]</span>, you have to do <span class="">[20,19..1]</span>.<br>
<br>-- ----------  End Quote<br><br></div><div>Why is this? If the first was greater than the second it would just subtract! Right?<br><br>-- ----------  ----------  ----------  ----------  ----------  <br><br>-- ---------- Start Quote<br>
<br>Watch out when using floating point numbers in ranges! Because they are 
not completely precise (by definition), their use in ranges can yield 
some pretty funky results.<br><br><span><span class="">ghci></span><span> [</span><span class="">0.1</span><span>, </span><span class="">0.3</span><span> .. </span><span class="">1</span><span>]</span></span><br><span>[<span class="">0.1</span><span>,</span><span class="">0.3</span><span>,</span><span class="">0.5</span><span>,</span><span class="">0.7</span><span>,</span><span class="">0.8999999999999999</span><span>,</span><span class="">1.0999999999999999</span><span>]</span></span><br>
<br></div>-- ---------- End Quote<br><br><div>Can anyone explain me why it works for the first few values, and not "completely"?<br><br>-- ----------  ----------  ----------  ----------  ----------  <br><br></div>
<div>Any thoughts?<br><br></div><div>Thank You Very Much in advance!<br><br></div><div>Gilberto<br></div></div>