[REBOL] Re: Maplist?
From: tim:johnsons-web at: 8-Sep-2001 14:23
On Sat, Sep 08, 2001 at 04:54:46PM -0400, David Ness wrote:
> I've look thru the documentation, but haven't had the answer to a very
> simple question jump out at me yet.
>
> Question:
> What converts ["123" "45667"] to [123 45667]
That's one question: here's one way to do it:
ndx: 1
loop length? test[change at test ndx to-integer test/:ndx ndx: ndx + 1]
== 3 ; the loop returns the final value of ndx
>> test ; let's look at test
== [123 45667]
;NOTE: 'test was changed
> or generalizing:
> How do I generate the block that is the result of applying some
> function to each element of an existing block (the classical
> Lisp `Maplist') function;
This is a different case, if I understand your question. A second
block would be created, and one would want to test the type of each
member of the source block
; you might have something like this:
dst: make block! length? test ; save memory reallocation internally
ndx: 1
loop length? test[append dst to-integer test/:ndx ndx: ndx + 1]
>> test
== ["123" "4567"] ; is not changed
>> dst
== [123 4567] ; new block as a result
> perhaps more importantly,
> what documentation should I look at that would point me in the
> direction to solutions to this class of problems...
If I've understood you here, the core user's manual goes into series
if great depth with charts and everything.
PS: I wish I know more about lisp, I think a knowledge of lisp
would add to the rebol "literature".
Perhaps you're the one?
HTH
Tim
> --
> To unsubscribe from this list, please send an email to
> [rebol-request--rebol--com] with "unsubscribe" in the
> subject, without the quotes.
--
Tim Johnson <[tim--johnsons-web--com]>
http://www.johnsons-web.com