Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Automation
- convertChar :: Char -> String
- convertChar '+' = "p"
- convertChar '-' = "n"
- convertChar '[' = "Branch ("
- convertChar ']' = ")"
- convertChar x = [x] ++ " (x-1)"
- convertCharNode :: Char -> String
- convertCharNode '+' = "p"
- convertCharNode '-' = "n"
- convertCharNode '[' = "Branch ("
- convertCharNode ']' = ")"
- convertCharNode x = [x] ++ " x"
- format :: [String] -> String
- format strs = foldr1 f strs where
- f a b | a == "Branch (" || head b == ')' = a ++ b
- f a b = a ++ " :#: " ++ b
- autoProgram :: String -> String
- autoProgram = format . (map convertChar)
- autoProgramNode :: String -> String
- autoProgramNode = format . (map convertCharNode)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement