[Tutor] is this a state machine?

Kirk Bailey idiot1 at netzero.net
Thu Aug 7 19:54:59 EDT 2003


BTW, it works.

def iswikiword(word):				# test to see is a wikiword
	caps='ABCDEFGHIJKLMNOPQRSTUVWXYZ'	# define capitalletters
	prior=0					# set inital state for flags
	count=0					# wikiwords have 2+transitions
	for letter in word:			# examine each letter
		if letter in caps:		# if it IS a capital letter,
			prior=1			# store that state
		else:					# and if not,
			if prior==1:		# but the previous one WAS,
				prior=0		# reset the flag,
				count=count+1	# anc count the transition!
			else:				# otherwise,
				pass 			# chill out.
	if count > 1:				# ok, the results are in;
		return 1				# if there are 2+, itis.
	else:						# and if not,
		return 0				# say so.



-- 

end

Cheers!
         Kirk D Bailey

  +                              think                                +
   http://www.howlermonkey.net  +-----+        http://www.tinylist.org
   http://www.listville.net     | BOX |  http://www.sacredelectron.org
   Thou art free"-ERIS          +-----+     'Got a light?'-Promethieus
  +                              think                                +

Fnord.






More information about the Tutor mailing list