Theory of Computation - Finite State Automata
An honest effort in tackling the fundamentals of program design must include an understanding of the basics of computation best embodied by automata theory, and our chosen software ecosystem fortunately makes available to us a rich set of visualization tools to assist us in learning these abstract concepts.
We will begin this investigation by utilizing a great library called automat, built specifically for this task, which will allow us to use AT&T's Graph-Visualization software to turn simple expressions into images to represent models of algorithms.
The simplest automaton is a chain of valid inputs, like [1 2 3]. We punch that into automat, and it spits out a nice pretty diagram for us:
> (view [1 2 3])

And then we can combine
them:
> (view (a/or [1 2 3] [1 3]))
[1 2 3]
or [1 3]
.Game designer Mark Engelberg, creator of instaparse, gave a brilliant demonstration of how this can be used to elegantly solve a classic programming puzzle called Maximum Segment Sum.
First we will state the problem:
Find the maximum sum achievable by adding up a segment of a sequence of numbers (typical input is a mix of positive and negative integers).
For example, the maximum-segment-sum of [-1 2 3 -4 5 -8 4] is 6,
because 2+3+-4+5 is 6.
Want to see the whole thing?
Comments
Post a Comment