home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / ckscripts / socrates < prev    next >
Text File  |  2020-01-01  |  1KB  |  72 lines

  1. # From: "Dat Nguyen" <thucdat@hotmail.com>
  2. # Subject: Is Socrates Mortal?
  3. # Date: Mon, 10 May 2004 11:08:39 -0400
  4. #
  5. # Prolog-like declarative logic programming in Kermit.
  6. #
  7. define being {
  8.     _asg \%1.being \m(\%1.being)|\%2
  9.     _asg \%2.having \m(\%2.having)|\%1
  10. }
  11.  
  12. define findtheTruth {
  13.     local \%i \&w[]
  14.     for \%i 1 \fsplit(\m(\%1.being),&w,|) 1 {
  15.         if > \find(\%2,\&w[\%i]) 0 return 1
  16.         findtheTruth \&w[\%i] \%2 
  17.         if success return 1
  18.     }
  19.     END -999999
  20. }
  21.  
  22. define isTrue {
  23.     findtheTruth \%1 \%2
  24.     if success {
  25.         echo yes
  26.         return 1
  27.     } else {
  28.         echo no
  29.         return 0
  30.     }
  31. }
  32.  
  33. define whois {
  34.     local \%i \&w[]
  35.     for \%i 1 \fsplit(\m(\%1.having),&w,|) 1 {
  36.         if not define \m(\&w[\%i].having) {
  37.             echo \&w[\%i]
  38.         }
  39.         whois \&w[\%i]
  40.     }
  41. }
  42.  
  43. being Socrates human
  44. being human mortal
  45.  
  46. being venus_williams tennisPlayer
  47. being tennisPlayer makeslotsmoney
  48. being makeslotsmoney rich
  49. being rich happy
  50.  
  51. being Donna makeslotsmoney
  52. being steffi_graf tennisPlayer
  53. being andre_aggassi tennisPlayer
  54.  
  55. # Is Socrates a human?
  56. isTrue Socrates human
  57.  
  58. # Is Socrates mortal?
  59. isTrue Socrates mortal
  60.  
  61. # Is Venus Williams a tennis player?
  62. isTrue venus_williams tennisPlayer
  63.  
  64. # Who is tennis player?
  65. whois tennisPlayer
  66.  
  67. # Who is human?
  68. whois human
  69.  
  70. # Who is rich?
  71. whois rich
  72.