Concepts

Transition table

Try the free JavaScript compiler

Represent a fixed finite transition policy explicitly; return the original phase for unknown pairs in this model.

Formal Syntax & Structure

javascript syntaxjavascript
table.get(state)?.get(event) ?? state

Working Example

Example Snippetjavascript
(async () => {const table=new Map([["closed",new Map([["OPEN","open"]])],["open",new Map([["CLOSE","closed"]])]]);const step=(s,e)=>table.get(s)?.get(e)??s;let state="closed";for(const e of ["OPEN","OPEN","CLOSE"])state=step(state,e);console.log(state,step(state,"UNKNOWN"));})()
JavaScript Reference