[REBOL] Re: On ordinal and cardinal numbers...
From: joel:neely:fedex at: 7-Jul-2001 11:56
Jeff Kreis wrote:
> > .. so that one could write it as
> >
> > repeatz i length? block [print [i pickz block i]]
>
> .. prints NONE on the last iteration I guess.
>
I'm really puzzled. Why would you guess that?
If BLOCK has N elements (for some N) ...
then LENGTH? BLOCK evauates to N
then REPEATZ I LENGTH? BLOCK is the same as REPEATZ I N
then REPEATZ I LENGTH? BLOCK takes I from 0 through N - 1
then [PRINT [I PICKZ BLOCK I]] on the last iteration is
the same as [PRINT [N - 1 PICKZ BLOCK N - 1]]
which prints the number N - 1, followed by the value of
PICKZ BLOCK N - 1, which is the last element of BLOCK.
Where did you get NONE?
> You sure you don't want LENGTHZ? too?
>
Why? The length of a series does not depend on how we
label its positions; whether use the labels
1, 2, 3, 4
or
0, 1, 2, 3
or
eenie, meenie, mienie, moe
this example still has four labels, therefore a length
of four.
-jn-
---------------------------------------------------------------
There are two types of science: physics and stamp collecting!
-- Sir Arthur Eddington
joel-dot-neely-at-fedex-dot-com