Talk:Continued fraction/Arithmetic/G(matrix ng, continued fraction n1, continued fraction n2): Difference between revisions

From Rosetta Code
(No difference)

Revision as of 11:16, 11 March 2013

Idiomaticity?

Is putting that many operations on a single line really idiomatic? Yes it makes the code short, but it also makes it very hard to read. Let's face it, newlines just aren't that expensive! (If I was doing a formal code review of this, I'd be complaining about it a lot…) The watchword of Rosetta Code is “idiomatic”; the code is meant to be read by other people in order to learn how to do a task with a particular language or to compare how different languages do the same thing. (I don't just write my Tcl solutions to be short, but rather to demonstrate how to write good Tcl code that can be read long after it was written and that takes advantage of the features of the language. YMMV, but I'd expect something similar; it's not just “look we can solve this” but “we can solve this and you can understand how we did it”.)

You might also like to refactor a bit so that the code to print out a sequence is a shared method. That's the sort of thing that makes an excellent candidate for not being written out every time. –Donal Fellows 12:10, 10 March 2013 (UTC)

Non-unique solutions

The solutions in C++ and Tcl have different answers to the computation of , but if you work the sequences out they are the same actual fraction; both are correct. I suspect this is due to differences of rounding semantics with mixed-sign integer division. –Donal Fellows 10:22, 11 March 2013 (UTC)