home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / eiffel / 1461 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  1.8 KB

  1. Path: sparky!uunet!crdgw1!rpi!gatech!udel!bogus.sura.net!opusc!usceast!jimmy.cs.cofc.edu!wilkins
  2. From: wilkins@cs.cofc.edu (Jimmy Wilkinson)
  3. Newsgroups: comp.lang.eiffel
  4. Subject: Is there a way to get the effect of Pascal's procedure parameters?
  5. Message-ID: <1993Jan27.230808.12959@usceast.cs.scarolina.edu>
  6. Date: 27 Jan 93 23:08:08 GMT
  7. Sender: usenet@usceast.cs.scarolina.edu (USENET News System)
  8. Organization: The College of Charleston
  9. Lines: 45
  10. X-Xxmessage-Id: <A78C8071F5021105@jimmy.cs.cofc.edu>
  11. X-Xxdate: Wed, 27 Jan 93 18:09:53 GMT
  12. X-Useragent: Nuntius v1.1.1d17
  13.  
  14. I'd like to be able to do in Eiffel something similar to the following
  15. (fragmentary) Pascal code:
  16.  
  17. program  demo(....);
  18.  
  19. type
  20.        PersonRecord = ............
  21.        PersAry = array[...] of PersRec;
  22.  
  23. var  pa : PersAry;
  24.  
  25. function DateLess(r1, r2 :PersonRecord) : boolean;
  26. begin
  27.   {Return TRUE is the date field in r1 is LESS than the one in r2;  else
  28. FALSE}
  29. end;
  30.  
  31. function ZipLess(r1, r2 :PersonRecord) : boolean;
  32. begin
  33.   {Return TRUE is the zip field in r1 is LESS than the one in r2;  else
  34. FALSE}
  35. end;
  36.  
  37. procedure Sort(var a : PersAry; function Precedes(r1, r2: PersonRecord) :
  38. boolean);
  39. begin
  40. {sort array a according to order established by Precedes}
  41. end;
  42.  
  43. begin     {main}
  44.   {establish pa and its contents}
  45.   Sort(pa, DateLess);
  46.   {do something with the array sorted into ascending order by date}
  47.   Sort(pa, ZipLess);
  48.   {do something with the array sorted into ascending order by zip code}
  49. end.
  50.  
  51. I can't find anything that will do this.  Does anyone in this group know
  52. whether it can be done and, if so, how?  Any help will be most
  53. appreciated.
  54.  
  55. -------------------------------------------------------------
  56. Jimmy Wilkinson             Professor of Computer Science
  57. wilkins@cs.cofc.edu        The College of Charleston
  58. (803) 792-8160              Charleston      SC        29424
  59.