<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I’m sort of seeing this as a foldr over a list of digit pairs with the seed value of the fold being the first step of the algorithm (which is different from the other steps).<div class="">The list of pairs will be of indeterminate length as ’00’ is used until the required number of digits in the result is achieved.</div><div class="">A minor wrinkle with this is if the input number is a perfect square then a lot of ‘0’s would be in the result.</div><div class=""><br class=""></div><div class="">Then, after the fold, apply some simple function to determine where the decimal point should go.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">M</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On 9 Sep 2017, at 05:49, KC <<a href="mailto:kc1956@gmail.com" class="">kc1956@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="auto" class="">One approach <div dir="auto" class=""><br class=""></div><div dir="auto" class="">One function to compute the next iterate</div><div dir="auto" class=""><br class=""></div><div dir="auto" class="">Another function to call the computation function until results are within some tolerance </div><div dir="auto" class=""><br class=""></div><div dir="auto" class="">It's usually presented as separation of control and computation 😎<br class=""><br class=""><div data-smartmail="gmail_signature" dir="auto" class="">--<br class="">Sent from an expensive device which will be obsolete in a few months<br class="">Casey</div></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sep 3, 2017 1:23 AM, "mike h" <<a href="mailto:mike_k_houghton@yahoo.co.uk" class="">mike_k_houghton@yahoo.co.uk</a>> wrote:<br type="attribution" class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Hi,<div class=""><br class=""></div><div class="">To help me in learning Haskell I started blogging about some of the things I’ve looked at. </div><div class="">One such topic was calculating square roots ‘by hand’ and then deriving a Haskell algorithm. </div><div class="">I wrote about the well known technique here</div><div class=""><a href="http://gitcommit.co.uk/2017/08/25/the-root-of-the-problem-part-1/" target="_blank" class="">http://gitcommit.co.uk/2017/<wbr class="">08/25/the-root-of-the-problem-<wbr class="">part-1/</a></div><div class=""><br class=""></div><div class="">and it it is really quite a simple method. </div><div class=""><br class=""></div><div class="">The second part of the post will be an implementation in Haskell. </div><div class=""><br class=""></div><div class="">I then tried implementing it and got something that works but really its not very pleasant to look at! And its something I don’t want to post! Some parts are fine but I think I locked myself into the notion that it had to be using State and really the end result is pretty poor. </div><div class=""><br class=""></div><div class="">I know this i perhaps a ‘big ask’ but I’d really appreciate any suggestions, solutions, hints etc. I will of course give full attribution. </div><div class=""><br class=""></div><div class="">I’ve created a gist of the code here</div><div class=""><a href="https://gist.github.com/banditpig" target="_blank" class="">https://gist.github.com/<wbr class="">banditpig</a></div><div class=""><br class=""></div><div class="">Many Thanks</div><div class=""><br class=""></div><div class="">Mike</div></div><br class="">______________________________<wbr class="">_________________<br class="">
Beginners mailing list<br class="">
<a href="mailto:Beginners@haskell.org" class="">Beginners@haskell.org</a><br class="">
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank" class="">http://mail.haskell.org/cgi-<wbr class="">bin/mailman/listinfo/beginners</a><br class="">
<br class=""></blockquote></div></div>
_______________________________________________<br class="">Beginners mailing list<br class=""><a href="mailto:Beginners@haskell.org" class="">Beginners@haskell.org</a><br class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners<br class=""></div></blockquote></div><br class=""></div></body></html>