Cantor set: Difference between revisions

m
(→‎{{header|Haskell}}: Tidied, pruned out an import.)
Line 1,376:
Or, using strings for the model as well as the display:
 
<lang haskell>cantor-------------------------- :: [String]CANTOR -> [String]-----------------------
 
cantor :: [String] -> [String]
cantor = (go =<<)
where
Line 1,385 ⟶ 1,387:
m = quot (length x) 3
block = take m x
 
--------------------------- TEST -------------------------
cantorLines :: Int -> String
cantorLines n =
unlines $ concat <$> take n (iterate cantor [replicate (3 ^ (n - 1)) '█'])
 
main :: IO ()
main = putStrLn $ cantorLines 5</lang>
 
 
------------------------- DISPLAY ------------------------
cantorLines :: Int -> String
cantorLines n =
unlines . (concat <$>)
. ( take
<*> ( iterate cantor
. return
. flip replicate '█'
. (3 ^)
. pred
)
)</lang>
{{Out}}
<pre>█████████████████████████████████████████████████████████████████████████████████
9,655

edits