Posted to tcl by GPS at Mon Sep 17 08:50:08 GMT 2007view raw

  1. proc what? {{this ""}} {
  2. puts -nonewline "what? $this "
  3. flush stdout
  4. string trim [gets stdin]
  5. }
  6.  
  7. proc how? {} {
  8. puts -nonewline "how? "
  9. flush stdout
  10. string trim [gets stdin]
  11. }
  12.  
  13.  
  14. proc ask-recurse {word} {
  15. global rules
  16. set rules([what? $word]) [set how [how?]]
  17. foreach w [split $how] {
  18. ask-recurse $w
  19. }
  20. }
  21.  
  22. proc ask this {
  23. global rules
  24. set rules([what? $this]) [set how [how?]]
  25. foreach word [split $how] {
  26. ask-recurse $word
  27. }
  28. }
  29.  
  30. proc main {} {
  31. global rules
  32. while {![eof stdin]} {
  33. ask ""
  34. }
  35. parray rules
  36. }
  37.