考虑到这些F#type声明。。。在
type Message =
| MessageA
| MessageB
| MessageC
| MessageD
type State = {
Name:string
NextStateMap: Map<Message,State>
}
……对于这个特定的状态机,有没有一个同样具有表达力的定义。。。在
^{pr2}$…用Python?在
注意,通过“rec”,我们不必按照拓扑排序定义的顺序进行赋值。。。(例如,state0是根据state1定义的,即使state1是在后面定义的)。在
另外,使用字符串作为状态标识符的选项。。。在
stateMachine = {
"0" : { "A":"1", "B":"2"},
"1" : { "B":"3" },
...
…保留无效键(即状态机中的无效消息说明符)的情况。在
在Python中,我认为您应该定义状态,然后设置映射。伪代码如下:
相关问题 更多 >
编程相关推荐