Recursive Functional State Machine

Category: Python - Miscellaneous

This is a simple state machine that takes a functional approach.
It requires trampoline from pysistence.func to avoid the recursion limit.

Namedtuples are used to define the different states.
globals() is used to reference the states. (This could also be done putting states into a separate module and getting them through getattr.)

In this recipe the functions called in the different states need to return a boolean, which defines the success or failure event. Date: 11 March, 2012


Functional - Recursion - State Machine

Homepage: http://code.activestate.com/recipes/577709-recursive-functional-state-machine/?in=lang-python

Developer: Stefan Tunsch

License: Freeware

Operating System: Windows

Add a Comment

all are required fields

     
What do you think of this resource?

Select Your Rate:

Votes:0

 

Related Scripts Download

Trellian CodePad is a FREE drop-in replacement for Windows NotePad.

developer Developer: http://www.trellian.com/...
license License: Freeware
operating systems Operating System: Windows 95/98/NT/2000/XP


This script provides all the basic functions, including finding the square root.

developer Developer: javascriptsource.com
license License: Freeware
operating systems Operating System: All


This scrip represents a tool for turning exception handling into functional alternation.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


The purpose of this module is to provide a dictionary and list type that can aid in relational algebra, functional programming, list-oriented programming, and perhaps even code obfuscation.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


When you're simulating a cookie, you have to go all the way.

developer Developer: snippets.dzone.com
license License: Freeware
operating systems Operating System: Windows, Linux


Sample shows practical way to get user input using functional decomp to create range testing and quit values into a well designed code block.

developer Developer: dreamincode.net
license License: Freeware
operating systems Operating System: Windows, Linux, BSD, Solaris


Decorator makes function currying as long as there are more correct arguments to take and fires it as soon as there is enough to call, also checks arguments up front for errors.

developer Developer: Przemyslaw Podczasi
license License: Freeware
operating systems Operating System: Windows


Pip has an option to upgrade a package (_pip install -U_), however it always downloads sources even if there is already a newest version installed.

developer Developer: Artur Siekielski
license License: Freeware
operating systems Operating System: Windows


The Python stdlib pwd module provides an easy way to get the primary group ID, but no way to get additional group IDs.

developer Developer: realityexists
license License: Freeware
operating systems Operating System: Windows