flowchart LR
auto1((Auto 1))
auto2((Auto 2))
auto3((Auto 3))
auto1 -->|Path 1| auto1
auto1 -->|Path 2| auto2
auto2 -->|Path 4| auto2
auto2 -->|Path 3| auto3
auto3 -->|Path 5| auto3
auto3 -->|Path 6| auto1
Last active
May 26, 2023 15:59
-
-
Save CornerSyrup/c0702987709f3fe1a085f22befbdcf73 to your computer and use it in GitHub Desktop.
Simple automata in javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path1 = () => auto1; | |
const path2 = () => auto2; | |
const auto1 = { | |
1: path1, | |
2: path2, | |
}; | |
const path3 = () => auto3; | |
const path4 = () => auto2; | |
const auto2 = { | |
3: path3, | |
4: path4, | |
}; | |
const path5 = () => auto3; | |
const path6 = () => auto1; | |
const auto3 = { | |
5: path5, | |
6: path6, | |
}; | |
let foo = [2, 3, 5].reduce((auto, path) => auto[path](), auto1); | |
console.log(foo); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment