Facebook
From Sweltering Duck, 8 Years ago, written in Haskell.
This paste is a reply to Untitled from Cute Cat - go back
Embed
Viewing differences between Untitled and Re: Untitled
thenA :: Auto a q1 -> Auto a q2 -> Auto a (Either q1 q2)
thenA (A s11 ini11 ac11 t11) (A s12 ini12 ac12 t12) = (A st init ac2 tr) where 
        (A s1 ini1 ac1 t1) = leftA (A s11 ini11 ac11 t11)
        (A s2 ini2 ac2 t2) = rightA (A s12 ini12 ac12 t12)
        st = s1 ++ s2
        init =  if any ac1 ini1 then 
                                ini1 ++ ini2 
                        else 
                                ini1
        tr (Left x) w = let l = t1 (Left x) w
                                                in        if (any ac1 l) then 
                                                                l ++ ini2
                                                        else 
                                                                l
        tr (Right x) w = t2 (Right x) w