Posted to tcl by GPS at Mon Sep 17 08:50:08 GMT 2007view raw
- proc what? {{this ""}} {
- puts -nonewline "what? $this "
- flush stdout
- string trim [gets stdin]
- }
- proc how? {} {
- puts -nonewline "how? "
- flush stdout
- string trim [gets stdin]
- }
- proc ask-recurse {word} {
- global rules
- set rules([what? $word]) [set how [how?]]
- foreach w [split $how] {
- ask-recurse $w
- }
- }
- proc ask this {
- global rules
- set rules([what? $this]) [set how [how?]]
- foreach word [split $how] {
- ask-recurse $word
- }
- }
- proc main {} {
- global rules
- while {![eof stdin]} {
- ask ""
- }
- parray rules
- }