[REBOL] Re: the utility of 'bind
From: tim:johnsons-web at: 21-Jan-2004 13:34
* Maxim Olivier-Adlhoch <[maximo--meteorstudios--com]> [040121 13:17]:
>
> > --- Tim Johnson wrote: ---
>
> > ; untested code!
> > context.....[
> > validate: func[args[block!] /local keywords][
> > keywords: self/__dict__
> > foreach [arg value] args[
> > if not find keywords arg[
> > throw-an-error
> > ]
> > ]
> > ]
> > ]
>
> another way to code the above (but this also support validating just one word):
>
> context [
> validate: func [word [block! word!] /local item][
> either block! = type? word [
> foreach item word [
> if not (validate item) [return false]
> ]
> return true
> ][
> either found? in self word [true][false]
> ]
> ]
> ]
>
> IMHO, I find this version a little bit more readable.
>
> tim, this is not a challenge to your coding skills...
:-) No problem.
See above. Untested code! Actually pseudo-code. I was just
translating how python would do it. And your method *is*
more rebol-esque (IMHO)
> I just like to
> show different views of a problem, for academic purposes.... this
> helps novices a lot.
And I find that seeing how different languages handle things
helps *me* alot. I wrote a 'first function for python that -
is more verbose than referencing by index but more clear...
especially when going from a language that references an
initial element as '1' to one that references an initial
element as '0'.
Permission to use your example?
thnx
tj
>
> -Max
>
> --
> To unsubscribe from this list, just send an email to
> [rebol-request--rebol--com] with unsubscribe as the subject.
--
Tim Johnson <[tim--johnsons-web--com]>
http://www.alaska-internet-solutions.com<