MKE 6.7 (Aug/5/2005) permits the use of and,or,not
in "if" statements. The propositions associated
with and,or,not are enclosed in braces.
The example below shows the correct syntax,
and the "alternate version" in the comments shows
how to achieve the same result without using and,or,not.
# KEHOME/test/andornot.ku
# Aug/5/2005
# test and,or,not in if statement
# alternate versions do not use and,or,not
add whole number isa method with
# Product = $1 + $2 for whole numbers (non-negative integers)
# simulate human method
format=[whole number:1, whole number:2],
local=[answer],
meaning={
if {$1 is 0;} and {$2 is 0;}; then set answer = 0; fi;
if {$1 is 0;} and not {$2 is 0;}; then set answer = $2; fi;
if not {$1 is 0;} and {$2 is 0;}; then set answer = $1; fi;
if not {$1 is 0;} and not {$2 is 0;}; then answer := do add natural number
od $1,$2 done; fi;
# alternate version 1
#if $1 is 0; then if $2 is 0; then set answer = $2; fi;fi;
#if $1 is 0; then if $2 is 0; else set answer = $2; fi;fi;
#if $1 is 0; else if $2 is 0; then set answer = $1; fi;fi;
#if $1 is 0; else if $2 is 0; else answer := do add natural number od $1,$2
done; fi;fi;
# alternate version 2
#if $1 is 0; then set answer = $2;
#else if $2 is 0; then set answer = $1;
#else answer := do add natural number od $1,$2 done;
#fi; fi;
set Product=$answer;
};
add natural number iss method with
# Product = $1 + $2 for natural numbers (positive integers)
# simulate human method
format=[natural number:1,natural number:2],
local=[count,answer],
meaning={
set echo=off;
set count = 1;
answer := do increase od $1 done;
until $count is $2 {
count := do increase od $count done;
answer := do increase od $answer done;
};
set echo=on;
set Product = $answer;
};
increase is method with
# Product = $1 + 1 for numbers (integers)
format=[number:1],
meaning={
# use MKE built-in method
do sum od $1,1 done;
};
# tests
do add whole number od 0,8 done;
do add whole number od 5,0 done;
do add whole number od 0,0 done;
do add whole number od 5,8 done;
do add whole number od 12,23 done;
#exit;
Dick McCullough
knowledge := man do identify od existent done;
knowledge haspart proposition list;
http://rhm.cdepot.net/