type cell = `Left_Long | `Right_Long | `Left_Short | `Right_Short ;; type anabaena = [cell]seq ;; S0 := seq:(`Right_Long) ;; anabaena(S0) ;; trans grammar = { `Right_Short => `Right_Long; `Left_Short => `Left_Long; `Right_Long => `Left_Long, `Right_Short; `Left_Long => `Left_Short, `Right_Long; } ;; fun output(S) = ( foreach c in S do switch c case `Right_Short: stdout << "r" case `Left_Short: stdout << "l" case `Right_Long: stdout << "R" case `Left_Long: stdout << "L" endswitch; stdout << "\n"; S ) ;; grammar[iter = 5, prelude = output, interlude = output, postlude = output ](S0) ;;