Skip to content

A Clojure library designed to create deterministic finite state machines.

License

Notifications You must be signed in to change notification settings

fbeline/fsm-clj

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fsm-clj

Clojars Project

A Clojure library designed to create deterministic finite state machines.

  • Easy to use flat one level state machine.
  • Define state machines that can accumulate values.
  • Transitions with actions and guards.
  • Graphically visualize the resulting state machines.

Refer to the documentation for more details.

Quick Start

Require the fsm-clj core name space.

(:require [fsm-clj.core :refer :all])

Define a simple traffic light state machine.

(defsm traffic-light
  [[:green -> :yellow when :to-yellow]
   [:yellow -> :red when :to-red]
   [:red -> :green when :to-green]])

Sending events.

(-> (traffic-light)
    (send-event :to-yellow)
    :state) ;; => :yellow

Graphically generate the State Machine (open a Swing viewer).

(show! (traffic-light))

Traffic Light Finite State Machine

License

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

A Clojure library designed to create deterministic finite state machines.

Resources

License

Stars

Watchers

Forks

Packages

No packages published