list - Transform from [[Char]] to own data type in Haskell -
this question exact duplicate of:
- scanl in haskell 1 answer
scanl (\exp y -> scanl (\x -> if (isletter x) update exp (literal x) "" else if x=='+' update exp epsilon "+" else if x=='*' update exp epsilon "*" else update exp epsilon "|") y) epsilon q
my data type is:
data reg = epsilon | literal char | or reg reg | reg reg | star reg deriving eq
and
update:: reg -> reg -> [char] -> reg update b "" = (a `then` b) update b "|"= (a `or` b) update b "*" = (star a) update b "+" = (plus a) update b "?" = (opt a)
and trying transform ["a|","bc"] (then (or b c)) using functions above , can't use parsec .
please don't "manually", end in mess. instead learn how use parser. parsec fine smaller examples, , more readable , flexible code.
Comments
Post a Comment