Convert decimal number to rational: Difference between revisions

Line 413:
 
=={{header|Haskell}}==
Note that the decimal values of the task description are truncated in some cases.
 
The first map finds the simplest fractions within a given radius. The last converts the string representation of the given values directly to fractions.
<lang haskell>Prelude> map (\d -> Ratio.approxRational d 0.0001) [0.9054054, 0.518518, 0.75]
[67 % 74,14 % 27,3 % 4]
Anonymous user