[REBOL] Re: Can I define an anti function?
From: lmecir:mbox:vol:cz at: 24-Feb-2004 17:55
Hi Romano,
>...but i agree, the :arg notation is never used and it requires a reference to a
>value instead of the "value itself", so it is not totally "correct" to be used
>it in context like this.
>
>About Scheme people, if they would speak "in general", they could be right: we
>cannot create an anti :do and anti :make which work in every situations, but
>if they speak only of strict bolean functions, i think they are wrong ;-)
>
That's the point I was prepared to make :-) If we translate "a function
returning boolean" to Rebol as a function always returning Logic! (for
any input), then we are safe as you said, because DO (as well as MAKE)
sometimes return different datatypes.
>...
>yes, i forgot to delay the get/any insertion after the bind to the function
>context.
>
>there are many modes to do it, and this is one of them:
>
....
yes. To present a solution, that looks as simple as possible, we can write:
anti: func [f [any-function!] /local exec] [
exec: func [block] reduce ['not 'apply 'first reduce [:f] 'block]
func load mold third :f reduce [:exec first :f]
]
, where the only missing part is an APPLY function, which takes a block
of words and passes their values to the function. An easy ;-) exercise
for the reader.
-L