Farey sequence: Difference between revisions

m
J: addressed "Incorrect" flag with documentation
(→‎{{header|J}}: flagged as incorrect (the output "format").)
m (J: addressed "Incorrect" flag with documentation)
Line 235:
=={{header|J}}==
 
J has an internal data representation for completely reduced rational numbers. This displays as integers where that is possible and otherwise displays as NNNrDDD where the part to the left of the 'r' is the numerator and the part to the right of the 'r' is the denominator.
{{incorrect|J| <br> First and last Farey terms aren't expressed as fractions as per the definition, <br> no terms shown are expressed as fractions, <br> (see the '''C''' programming example's output as an example). <br> }}
 
This mechanism is a part of J's "constant language", and is consistent with scientific notation (which uses an 'e' instead of an 'r') and with complex number notation (which uses a 'j' instead of an 'r'), and which follow similar display rules.
 
This mechanism also hints at J's type promotion rules are designed to give internally consistent results a priority. As much as possible you do not get different results from the same operation just because you "used a different data type". J's design adopts the philosophy that "different results from the same operation based on different types" is likely to introduce errors in thinking. (Of course there are machine limits and certain floating point operations tend to introduce internal inconsistencies, but those are mentioned only in passing - they are not directly relevant to this task.)
 
<lang J>Farey=:3 :0
6,962

edits