home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / prolog / 1526 < prev    next >
Encoding:
Internet Message Format  |  1992-08-13  |  1.0 KB

  1. Path: sparky!uunet!mcsun!uknet!bcc.ac.uk!link-1.ts.bcc.ac.uk!ucjtrjf
  2. From: ucjtrjf@ucl.ac.uk (Jonny Farringdon)
  3. Newsgroups: comp.lang.prolog
  4. Subject: Re: fuzzy unification of floating point numbers
  5. Message-ID: <1992Aug13.133930.25900@bas-a.bcc.ac.uk>
  6. Date: 13 Aug 92 13:39:30 GMT
  7. References: <1992Aug12.210954.15241@cs.ucla.edu>
  8. Organization: Bloomsbury Computing Consortium
  9. Lines: 31
  10.  
  11. >Does anybody know the prolog for UNIX which supports
  12. >the fuzzy unification of floating point numbers,     
  13. >that is two floating point numbers are considered 
  14. >equal if | X - Y | =< FUZZVALUE  and this FUZZVALUE
  15. >can be changed by user? I know that VM/Prolog has
  16. >this feature, but it works on mainframe.
  17. >Any information is appreciated.
  18.  
  19. Mike,
  20.  
  21. each time you want to do
  22.  
  23. thing(A,B) :- 
  24.     a = b, 
  25.     important_thing.
  26.  
  27. do:
  28.  
  29. thing(A,B) :-
  30.     fuzzy_equality_test(A,B),
  31.     important_thing.
  32.  
  33. fuzzy_equality_test(A,B) :-
  34.     fuzzy_unify_value(V), !,
  35.     Diff is A - B,
  36.     absolute_value(Diff,Abs_Diff),
  37.     Abs_Diff < V.
  38.  
  39. fuzzy_equality_test(A,A) :- !.
  40.  
  41. J.  ucjtrjf@ucl.ac.uk
  42.