3 ms·
That's not a Haskell question per se, but in any language you can implement it using two intergers (a, b) that represent the number a + b * sqrt(5).
by tome 13y ago
That's not a Haskell question per se, but in any language you can implement it using two intergers (a, b) that represent the number a + b * sqrt(5).
- wslh 13y agoYes, it is a Haskell question more than you think ;-) since, for example, using types for fraction or other kind of patterns can work different in Haskell than in other languages. I think it's possible in Haskell to add symbolic manipulation as well like in http://christopherolah.wordpress.com/2012/06/01/hasksymb-an-experiment-in-haskell-symbolic-algebra/ http://christopherolah.wordpress.com/2012/06/01/hasksymb-an-... or http://homepages.inf.ed.ac.uk/wadler/realworld/docon2.html http://homepages.inf.ed.ac.uk/wadler/realworld/docon2.html Also, there are implementations in the list that can be implemented in the same way on non functional languages.
- tome 13y agoI think it would be neater doing it in Haskell than, say Java, but the fundamental idea would be the same in both.