Cantor set: Difference between revisions

Content added Content deleted
m (→‎{{header|Phix}}: added syntax colouring the hard way)
Line 891: Line 891:
Or, using strings for the model as well as the display:
Or, using strings for the model as well as the display:


<lang haskell>import Data.Bool (bool)
<lang haskell>cantor :: [String] -> [String]

cantor :: [String] -> [String]
cantor = (go =<<)
cantor = (go =<<)
where
where
go x =
go x
| '█' == head x = [block, replicate m ' ', block]
let m = quot (length x) 3
block = take m x
| otherwise = [x]
where
in bool [x] [block, replicate m ' ', block] ('█' == head x)
m = quot (length x) 3
block = take m x


cantorLines :: Int -> String
cantorLines :: Int -> String