Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Can I define an anti function?

From: lmecir::mbox::vol::cz at: 23-Feb-2004 20:55

Doc draw my attention to the %subject%, which was discussed at comp.lang.scheme. The thread started with: {Suppose f is a function returning a boolean.Is there a way of defining a function anti, which, when given f, returns "not f"?} the discussion continued: {
> > > > (define (anti f) > > > > (lambda args > > > > (not (apply f args)))) > > Why is this objectionable? It provides the ability to do something that > > hardly any other languages can do.
} {
> This last statement is a bit too strong, even in Python you can do
Sheesh, I clearly said "hardly any other languages", not "no other languages". I stand by my original statement -- most programming languages can't do this. Python and Scheme are some of the few that can. C can do it for functions of a specific arity, but can't generalize (e.g. you can write anti_f1 for 1-argument functions, anti_f2 for 2-argument functions, etc.) } { I expect most general-purpose dynamically typed languages can, at least those using a conventional syntax. Perl can, Ruby can (but its treatment of higher orded functions is weird), Dylan can, and probably all Lisp variants too. Smalltalk can't because variable arity doesn't make sense: the method name implies the arity syntactically. Rebol probably can't: here the arity of a function tells how many words to parse as its argument and where the next function call begins. Forth and Postscript can't. Among statically typed languages C# can, and it's the only one I know. } Question: Is the guess about Rebol correct? (I will post my answer later) -L