home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / scheme / 2590 < prev    next >
Encoding:
Text File  |  1992-11-14  |  1008 b   |  35 lines

  1. Newsgroups: comp.lang.scheme
  2. Path: sparky!uunet!think.com!ames!pasteur!volga.Berkeley.EDU!matt
  3. From: matt@volga.Berkeley.EDU (Matt Wright)
  4. Subject: Re: arity problem
  5. Message-ID: <1992Nov13.180132.5267@pasteur.Berkeley.EDU>
  6. Sender: nntp@pasteur.Berkeley.EDU (NNTP Poster)
  7. Nntp-Posting-Host: volga.berkeley.edu
  8. Organization: University of California, at Berkeley
  9. References: <1992Nov12.234655.12264@newssrv.edvz.univie.ac.at>
  10. Date: Fri, 13 Nov 1992 18:01:32 GMT
  11. Lines: 22
  12.  
  13. Erich Neuwirth writes:
  14. >i want to do the following:
  15. >i need a function which takes a logical function as input and
  16. >returns the function which is just the negation.
  17.  
  18. (define (negate f)
  19.    (lambda args
  20.       (not (apply f args)) ))
  21.  
  22.  
  23. If the first "argument" to lambda isn't a list, then the function that's
  24. returned takes any number of arguments.
  25.  
  26. You can also say
  27.  
  28. (lambda (foo bar . baz)
  29.     ...)
  30.  
  31. Meaning two or more arguments.  The first is foo, the second is bar, and the
  32. rest (if any) are put in a list that baz is bound to.
  33.  
  34. -Matt
  35.