509 Views
.NET does not provide an integer square root function for the BigInteger type in F#. In this article the author has built a square root function that takes a BigInteger and returns a BigInteger. Read entire article to see the code.
4 comments
dpeterson
10/11/2011 11:27:29 PM
Not sure when I would ever need that in the type of work that I do normally, but it's very cool nonetheless to see the entire solution worked out in F#. Seems like math is very natural in F#.
bradygaster
10/12/2011 10:21:49 AM
Indeed. The more F# articles I read the more I want to investigate it. I do wish there were more real-world, LOB-style examples of how to use F# out there but I guess everything comes in time. :)
dpeterson
10/12/2011 10:36:18 AM
I could see it being useful in LOB apps like stock apps or other apps with lots of charting/math. Not sure if it does math any faster as it's still all on the CLR, but I suppose it's possible the F# compiler is better at math. Regardless, math is definitely more natural in F#.
Noldorin
10/12/2011 12:10:01 PM
While this article is a good and unique introduction to functional programming, it should be noted that the algorithm itself (the application of the Newton-Raphson in this case) is not particularly efficient. The Wikipedia page <http://en.wikipedia.org/wiki/Methods_of_computing_square_roots> offers some better algorithms.