[REBOL] Re: A "supercharged" Map function.
From: brett:codeconscious at: 23-Jul-2003 11:48
Hi Andrew,
> I think you meant:
> map :parse [ [1] [integer!] [a 2] [word! integer!]]
Yep thanks.
> As for evaluation of the series elements, if one wants the series
> elements evaluated:
>
> map :add reduce [now/date 3 now/date 4]
>
>Using 'reduce would seem to be easier and fit better with Rebol?
My first version evaluated the series as well. In effect the function was
evaluating its arguments. I figured then, in that case, I may as well allow
expressions to be the series elements. So the input becomes a series of
expressions rather than a series of values. So I feel my second version is
more useful than my first. This may not be in the spirit of map - I don't
know.
...fit better with Rebol?
It is a good question. My second version is very
similar in capability to reduce - which implies that maybe I've gone to far
(no suprise!). I think you're right to imply that map should not overlap
with reduce. One reason I can see is that my function cannot process a
series of words (they get evaluated).
So how then can one write a map function that does not evalate the series
elements when the mapping function has multiple arguments - and preferrably
do it fairly concisely? If there isn't a way I may as well stick with what
I have.
> And now what we really need is a 'map shootout! :)
I think there might have been an informal one some time ago, but I don't
recall seeing any versions handle a mapping function with multiple
arguments. But yes, improved versions eagerly awaited here!
Regards,
Brett.