[TriLUG] What about this is functional programming, and what about it isn't
slitt at troubleshooters.com
Tue Mar 4 11:16:39 EST 2014
Tomorrow night at GoLUG I'm presenting on "Design Patterns in
Python", with one pattern being functional programming.
Being a firm believer in data-centered programming, functional
programming doesn't come easy to me, but I have to include it. So I made
the most functional program I could in 10 hours, the tic-tac-toe
What I need is feedback about what is, and what is not, functional
programming within this program. Then I'll just point out to the
audience what is, and is not, functional programming, and get the point
across. For instance, if I had to guess, it would be something like
* The main logic isn't iteration, it's let_human_move() and
machine_moves_now() repeatedly call each other recursively, so at
the top level there's no state but the function args and returns.
* With the exception of a few prints and a couple input accepts, no
function has side effects: Each function's effect is only on the
* Every function's return value is affected only by the function's
* I'm passing around, as an argument and as a return, a huge piece of
state called "board".
* The internals (implementation) of many of the functions are extremely
state rich and contain lots of state-depending loops.
I'm sure some of you know a lot more about functional programming than
I do, so it would help me a lot if you could tell me what is, and what
is not, functional programming within this tic-tac-toe program.
Steve Litt * http://www.troubleshooters.com/
Troubleshooting Training * Human Performance
More information about the TriLUG