You know it's a good winter's day in Chicago when it doesn't matter if your shoelaces are tied; when the wind picks them up and holds them several inches above your shoes, there's really no way you can trip over them.
The death of McDonalds: http://veggiebite.net/
I am going to start raising funds for the Get-Jata-A-Mac Charitable Trust.
Why: Because I can no longer succeed in computer science with the Operating-System-That-Shall-Not-Be-Named, as my professor has duly informed me.
Funds needed: Approx. $2000
Desired hardware: 15" 2.16GHz MacBook Pro (160GB HD)
**If you are interested in donating, please contact me asap.**
Apparantly the federal deficit will be gone in five years.... Whatever you say, Dubya. Although to be fair, he did cut our deficit in half way ahead of schedule, and he has some interesting ideas in regards to insurance, taxation, and health care. Ah, well. Happy State of the Union.
Constructive criticism for my finite state machine? Enjoy...
#! /usr/bin/python2.4
#####
######################################
# Created by: Parijata Mackey on Mon Jan 22 2007
# Purpose: Simulate a Finite State Machine
# Contract: fsm string -> "accept" or "reject"
# Filename: mackey_fsm.py
######################################
#####
# Import modules, initialize variables.
import ConfigParser
import sys
import string
accepting = 'false'
# Process input from cmd line.
fsm_data = open(sys.argv[1])
inputs - sys.argv[2]
# Process fsm file from argv[1]. Define states (set of names), currstate (set of current states), accstate (set of accepting states).
config = ConfigParser()
config.readfp(fsm_data)
states = config.get('states','names').split(',')
currstate = config.get('states','start')
accstate = config.get('states','end').split(',')
#####
# Create a dictionary to be filled.
filldict = {}
# Create transition function dictionaries and put them in a list.
for state in states:
state = state.strip()
links = {}
paths = config.get('transitions',state).split('.')
for path in paths:
p = path.strip()[0]
if links.has_key(p):
errormsg = "Reject: Nondeterministic automata: ' + path.strip() + ' and '+ p + ':' +
links[p]
print errormsg
# Detects nondeterministic automata and exits early.
sys.exit(1)
else:
links[p] = path.strip()[2:]
#####
# Put filldict into a list; retrieve correct dictionary from list based on currstate.
filldict[state] = links
for i in inputs:
if filldict.has_key(currstate):
links = filldict[currstate]
else:
errormsg = 'Reject: Nonexhaustive transition function: Current state (' + currstate + ') has no transition state.'
print errormsg
# Detects nonexhaustive transition function and exits early.
sys.exit(1)
#####
# If there is a path, follow it. (ancient druid custom)
if links.has_key(i):
currstate = links[i]
elif links.has_key('*'):
currstate = links['*']
else:
errormsg = 'Reject: Nonexhaustive transition function: missing + i'
print errormsg
# Detects nonexhaustive transition functino and exits early.
#####
# Determine if accepting state is reached. Set accepting state if reached to "True", if not reached, well, too bad.
for loc in accstate:
if currstate == loc:
print 'Accept: For this state, Accepting state reached successfully.'
else:
print 'Reject: For this state, Failed to reach accepting state.'
Tuesday, January 23, 2007
:: in ur labz,
:: hackin ur genomes
About Me
- Name: Parijata Mackey
- Location: Chicago, IL
"Nothing shocks me. I'm a scientist." -Indiana Jones
Previous Posts
- Quantum biology... those words send tingles down m...
- //incoherent_babblingIs it worth it, really, to be...
- Alas, There is no hope for the human race...http:/...
- "How is it that hardly any major religion has look...
- The Chicago ONE Campaign is a group for people in ...
- Harry Potter and the Deathly Hallows.... Hurry up,...
- Google to catalog human genome, and create super h...
- "De-throning man is at the heart of most revolutio...
- Question of the Day: Why am I so offended by the v...
Subscribe to
Posts [Atom]
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home