home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / scheme / 2587 < prev    next >
Encoding:
Internet Message Format  |  1992-11-14  |  1.2 KB

  1. Path: sparky!uunet!think.com!barmar
  2. From: barmar@think.com (Barry Margolin)
  3. Newsgroups: comp.lang.scheme
  4. Subject: Re: arity problem
  5. Date: 13 Nov 1992 17:51:21 GMT
  6. Organization: Thinking Machines Corporation, Cambridge MA, USA
  7. Lines: 21
  8. Message-ID: <1e0pupINNgp6@early-bird.think.com>
  9. References: <1992Nov12.234655.12264@newssrv.edvz.univie.ac.at>
  10. NNTP-Posting-Host: telecaster.think.com
  11.  
  12. In article <1992Nov12.234655.12264@newssrv.edvz.univie.ac.at> A4422DAB@vm.univie.ac.at (Erich Neuwirth) writes:
  13. >i want to do the following:
  14. >i need a function which takes a logical function as input and
  15. >returns the function which is just the negation.
  16. >as long as i know the arity of the input function it is easy
  17. >to write this meta function just uning lambda, but i want this
  18. >operation to work with functions of any arity (=number of arguments)
  19. >in the best case it even should work with functions with variable arity.
  20. >is there a way to acomplish this?
  21.  
  22. The function it returns should take any number of arguments and just pass
  23. them along with apply:
  24.  
  25. (define (inverse f)
  26.   (lambda args (not (apply f args))))
  27.  
  28. -- 
  29. Barry Margolin
  30. System Manager, Thinking Machines Corp.
  31.  
  32. barmar@think.com          {uunet,harvard}!think!barmar
  33.