README.md

automata.r

Flexible state machine builder and associated tools for R. The aim is to evolve the package publicly for the next few months then release it to CRAN.

The aim of the package is two fold:

  1. Make it easy to definite state machines over standard R functions - Very valuable when you're trying to express and maintain complicated workflows.

  2. Introduce guard functions and function overloading - Makes it possible to create many variants of the same function, that only runs when certain conditions are met . E.g. define {function} as {definition} when {constrains when it's applicable}

Package exposes seven functions which together expose enough functionality to define and parameterise a state machine:

The functions are joint together using the magrittr notation. E.g.

INIT %>% 
  BEGIN_AUTOMATA("My Automata #1", start="goState") %>%
    VAR("some setting", F) %>%
    VAR("some other setting",T) %>%
    STATE("goState", as=function(state) {print("Whoooo!");state}, when=function(state)T) %>%
    STATE("delay", as=function(state){Sys.sleep(1);state}, when=function(state)T) %>%
    STATE("end", as=function(state){print("fin.");state}, when=function(state)T) %>%
    TRANSITION("goState","delay", when=function(state)T) %>%
    TRANSITION("delay","end", when=function(state)T) %>%
    TRANSITION("end","goState", when=function(state)T) %>%
  END_AUTOMATA %>%
  BEGIN_AUTOMATA("My Automata #2", start="start") %>%
    ...etc...
  END_AUTOMATA %>%
EXEC

One can execute as many automata as one wishes at the same time. Automata may run temporarily or forever.



emiruz/automata.r documentation built on May 16, 2019, 5:09 a.m.