You are viewing a single comment's thread. Return to all comments →
Can be super concise in Haskell!
splitNodeAt j seglen = map (\x -> [j - x, j + x]) [1..seglen] treeColumns _ 0 _ = [[]] treeColumns j segLen d = (if d > 0 then replicate segLen [j] ++ splitNodeAt j segLen else replicate (2 * segLen) []) ++ zipWith (++) (treeColumns (j - segLen) (segLen `div` 2) (d - 1)) (treeColumns (j + segLen) (segLen `div` 2) (d - 1)) generateLine len indices = map (\i -> if i `elem` indices then '1' else '_') [0..len-1] main = getLine >>= (putStrLn . unlines . reverse . map (generateLine 100) . treeColumns 49 16 . read)
Seems like cookies are disabled on this browser, please enable them to open this website
Functions and Fractals - Recursive Trees
You are viewing a single comment's thread. Return to all comments →
Can be super concise in Haskell!