Re: compare() and equal()
- Posted by Igor Kachan <kinz at peterlink.ru> Apr 10, 2001
- 516 views
Dear Eu users: On this subject, I like Eu because of Eu's semantic logic and syntax. Try please program below, remember compare() returns -1 or 0 or +1 equal() returns 1 or 0 -------------------------program sequence a,b,c,d,e integer n a={1,1} b={2,2} c={3,3} d={4,4} e={1,1} n=1 if compare(a,b)=+1 then n=2 elsif compare(a,c)=-1 then ---< non-equal a<c n=3 elsif compare(a,e)= 0 then n=4 elsif compare(d,a)=+1 then n=5 elsif compare(a,c)=+1 then n=6 end if ?n-1 n=1 if compare(a,b)=+1 then n=2 elsif compare(a,c)=+1 then n=3 elsif compare(a,c)= 0 then n=4 elsif compare(d,a)=+1 then ---< non-equal d>a n=5 elsif compare(a,c)=+1 then n=6 end if ?n-1 ------------ function same(object x, object y) return compare(x,y)=0 end function n=1 if same(a,b) then n=2 elsif same(a,c) then n=3 elsif same(a,e) then ---< equal n=4 elsif same(a,d) then n=5 elsif same(a,c) then n=6 end if ?n-1 ------------ function other(object x, object y) return compare(x,y)!=0 end function n=1 if other(a,b) then n=2 elsif other(a,c) then n=3 elsif other(a,e) then ---< equal n=4 elsif other(a,d) then n=5 elsif other(a,c) then n=6 end if ?n-1 -------------- n=1 if equal(a,b) then n=2 elsif equal(a,c) then n=3 elsif equal(a,e) then ---< equal n=4 elsif equal(a,d) then n=5 elsif equal(a,c) then n=6 end if ?n-1 ------------------------- function different(object x, object y) return not equal(x,y) end function n=0 if different(a,b) then n=1 elsif different(a,c) then n=2 elsif different(a,e) then n=3 ---< equal elsif different(a,d) then n=4 elsif different(a,c) then n=5 end if ?n ---------------------end of program And so on, bigger(), lager(), smaller(), lesser(), not_bigger(), not_lager(), not_smaller(), not_lesser()... Regards, Igor Kachan kinz at peterlink.ru