SyntaxHighlighter

Thursday, August 25, 2011

print text-graph in haskell!

Recently, I've been fascinated by haskell. Here's my take on the same problem in the previous post solved in haskell.
print_chars_list :: [Int] -> Char -> IO ()
print_chars_list [] _ = putStr ""
print_chars_list (x:xs) c = do
    putStrLn (take x $ repeat c)
    print_chars_list xs c

-- example
print_chars_list [1,5,4,6,2] '."

No comments:

Post a Comment