Cantor set: Difference between revisions
→Dual representation
Line 1,415:
===Dual representation===
Intervals as fraction pairs, and intervals as graphic bars:
<lang haskell>import
import Data.Bifunctor (bimap)
import Data.List (intercalate, mapAccumL, maximumBy)
import Data.Ratio (Ratio, denominator, numerator, (%))
Line 1,463 ⟶ 1,465:
('(' :) . (<> ")")
. intercalate ") ("
. fmap
(uncurry ((<>) . (<> ", ")) . join bimap showRatio)
showRatio :: Rational -> String
Line 1,472 ⟶ 1,473:
go x
| 1 /= x = '/' : show x
| otherwise = []</lang>
{{Out}}
<pre>(0, 1)
|