home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
scripts
/
ckermit
/
socrates.~1~
< prev
next >
Wrap
Text File
|
2004-05-09
|
1KB
|
72 lines
# From: "Dat Nguyen" <thucdat@hotmail.com>
# Subject: Is Socrates Mortal?
# Date: Mon, 10 May 2004 11:08:39 -0400
#
# Prolog-like declarative programming in Kermit.
#
define being {
_asg \%1.being \m(\%1.being)|\%2
_asg \%2.having \m(\%2.having)|\%1
}
define findtheTruth {
local \%i \&w[]
for \%i 1 \fsplit(\m(\%1.being),&w,|) 1 {
if > \find(\%2,\&w[\%i]) 0 return 1
findtheTruth \&w[\%i] \%2
if success return 1
}
END -999999
}
define isTrue {
findtheTruth \%1 \%2
if success {
echo yes
return 1
} else {
echo no
return 0
}
}
define whois {
local \%i \&w[]
for \%i 1 \fsplit(\m(\%1.having),&w,|) 1 {
if not define \m(\&w[\%i].having) {
echo \&w[\%i]
}
whois \&w[\%i]
}
}
being Socrates human
being human mortal
being venus_williams tennisPlayer
being tennisPlayer makeslotsmoney
being makeslotsmoney rich
being rich happy
being Donna makeslotsmoney
being steffi_graf tennisPlayer
being andre_aggassi tennisPlayer
# Is Socrates a human?
isTrue Socrates human
# Is Socrates mortal?
isTrue Socrates mortal
# Is Venus Williams a tennis player?
isTrue venus_williams tennisPlayer
# Who is tennis player?
whois tennisPlayer?
# Who is human?
whois human
# Who is rich?
whois rich