Mailing List Archive: 49091 messages

## [REBOL] On ordinal and cardinal numbers...

### From: g::santilli::tiscalinet::it at: 6-Jul-2001 18:55

```
(Dedicated to Jeff and Joel :)

I didn't want to partecipate to the "indexing" thread... but I
couldn't resist pointing out my point of view. I promise I'll keep
this message as short as possible; I'll send a personal mail with
all the reasoning for the following to anyone that really wants to

- Ordinal numbers and Cardinal numbers are different things. I
see everyone here seems to confuse the two concepts. The set of
cardinal (i.e. natural) number is {0, 1, 2, 3, ...} and is
defined by the axioms presented by Joel. The set of ordinal
numbers has nothing to do with the above, and is {1st, 2nd,
3rd, ...}. Jeff, please notice that the set of ordinal numbers
does not contain the symbol 0th or zeroeth. This monster exists
for other reasons, which I think I can explain if you want.
- The two sets above CAN be put in 1-1 relationship. The common
1-1 relationship between the two is {(0, 1st), (1, 2nd), (2,
3rd), ...} which says that 0 is the first natural number, 1 is
the second natural number, and so on. Please notice that REBOL
perfectly agrees with this:
>> N: [0 1 2 3 4 5 6 7 8 9 10 11 12] ; and so on... imagine this being infinite
== [0 1 2 3 4 5 6 7 8 9 10 11 12]
>> first N
== 0
>> second N
== 1
>> third N
== 2
Again, Jeff: 0 is not the zeroeth natural number. It is the
FIRST natural number, as REBOL correctly reports.
- REBOL's series functions are perfectly consistent as long as
you view them in the right prospective. PICK does not accept a
natural number as is second arguments; it requires an ordinal
number instead. (Pity REBOL does not include an ordinal!
datatype, of course Carl thought it was superflous to add since
the set of ordinal numbers can be represented by a subset of
the set of natural numbers (i.e. N - {0}); unfortunately this
seemed to create a certain confusion amongst REBOL users.)
Actually, REBOL's series function use a generalization of
ordinal numbers, because in REBOL positions can be considered
both by "looking forward" and by "looking backward" from the
current series "index" (or maybe I should use the term
"cursor"?). The first element "looking forward" is represented
by the symbol 1st, while the first element "looking backward"
is represented by the symbol -1st. So the set of ordinal
numbers is actually for REBOL:
{... -3rd, -2nd, -1st, 1st, 2nd, 3rd, ...}
which REBOL represents using the subset of Z:
{... -3, -2, -1, 1, 2, 3, ...}
This set DOES NOT contain 0. So it is perfectly consistent for
PICK to fail on a second argument of 0, since 0 IS NOT an
ordinal number.
- Other languages do not really have a concept of "series" which
is a more general concept than that of vector or array; also,
other languages tend to use relative positioning of elements
inside vectors, while REBOL's series use absolute positioning
using ordinal numbers. You can't just say that absolute
positioning is wrong, while relative is right. (Note for
Ladislav: of course PICK and AT are not 0 based nor 1 based;
they do not use relative positioning!)
Also, REBOL allows relative positioning too, thru the function
SKIP. So, in the case where you really need a PICK function
that accepts an integer as its second argument (considering it
as a distance to the first element of the series) you can use:

my-pick: func [series offset] [pick skip series offset 1]

(Ok, I'll shut up now... this is already way too long!)

Not 0 based nor 1 based,
Gabriele.
--
Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer
Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/
```