<div dir="ltr"><br><br>On Friday, May 6, 2016 at 6:46:26 PM UTC-5, Michael Litchard wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir="ltr"><div><div>I've been working on a project that needs a good fibonacci generator, and I'm to the point where can now improve upon this one: <br><a href="https://wiki.haskell.org/The_Fibonacci_sequence#Fastest_Fib_in_the_West" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.haskell.org%2FThe_Fibonacci_sequence%23Fastest_Fib_in_the_West\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFzix5dbPVZ36_StXEF6yTYuaAg4w';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.haskell.org%2FThe_Fibonacci_sequence%23Fastest_Fib_in_the_West\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFzix5dbPVZ36_StXEF6yTYuaAg4w';return true;">https://wiki.haskell.org/The_<wbr>Fibonacci_sequence#Fastest_<wbr>Fib_in_the_West</a><br><br></div>thanks to this guy:<br><a href="https://groups.google.com/forum/#!topic/haskell-cafe/HUgbAUCvCp4" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/forum/#!topic/haskell-cafe/HUgbAUCvCp4';return true;" onclick="this.href='https://groups.google.com/forum/#!topic/haskell-cafe/HUgbAUCvCp4';return true;">https://groups.google.com/<wbr>forum/#!topic/haskell-cafe/<wbr>HUgbAUCvCp4</a><br><br></div>He suggested breaking up a guard into two diffeent functions, which I can do, but I don't know what to call them because I don't know why the operations are different. I'm referring to this section:<br><br><pre><span>fib'</span> <span>(</span>f<span>,</span> g<span>)</span> p
<span>|</span> p <span>=</span> <span>(</span>f<span>*</span><span>(</span>f<span>+</span><span>2</span><span>*</span>g<span>)</span><span>,</span> f<span>^</span><span>2</span> <span>+</span> g<span>^</span><span>2</span><span>)</span>
<span>|</span> <span>otherwise</span> <span>=</span> <span>(</span>f<span>^</span><span>2</span><span>+</span>g<span>^</span><span>2</span><span>,</span> g<span>*</span><span>(</span><span>2</span><span>*</span>f<span>-</span>g<span>)</span><span>)<br><br>I'd like to know the reason why each guard does two entirely different things, so I know what to call the functions when I seperate them out.<br></span></pre></div></blockquote><div><br></div><div>Clearly `p` is a Bool, and it comes from the expression:</div><div><br></div><div> map (toEnum . fromIntegral) $ unfoldl divs n</div><div><br></div><div>What's going on in `toEnum . fromIntegral` is that a remainder (either 0 or 1 - it blows up for anything else) is being converted to a Bool, with 0 mapping to False and 1 mapping to True. So `isOdd` would be a more descriptive name for `p`.</div><div><br></div></div>