home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / gofer230.zip / Progs / Gofer / Demos / temps.gs < prev    next >
Text File  |  1994-06-23  |  490b  |  16 lines

  1. -- Representation of temperatures on both Fahrenheit and Celsius scales
  2. --
  3. -- This program cannot be used on any machine without support for floating
  4. -- point numbers within Gofer (e.g. PCs).
  5.  
  6. data Temp = Celsius Float | Fahrenheit Float
  7.  
  8. fahrToCent f = (f-32.0)/1.8
  9.  
  10. instance Eq Temp where
  11.     Celsius c1    == Celsius c2    = c1==c2
  12.     Celsius c1    == Fahrenheit f2 = c1==fahrToCent f2
  13.     Fahrenheit f1 == Celsius c2    = fahrToCent f1==c2
  14.     Fahrenheit f1 == Fahrenheit f2 = f1==f2
  15.  
  16.