[REBOL] Re: Millennium + 1 ...
From: lmecir:mbox:vol:cz at: 5-Jan-2001 20:06
My point of view written in Rebol:
pick-prop: function [
{Returns the value at the specified place in a series.}
[catch throw]
series [series!]
index [integer!]
/back {pick backwards}
/or
handler [block!] {exception handler}
] [to-skip skipped] [
to-skip: either back [- index] [index - 1]
either any [
tail? skipped: skip :series to-skip
all [
head? :skipped
head? skip :series to-skip + 1
]
] [
either or [do handler] [
throw make error! {Cannot pick}
]
] [first :skipped]
]
A user can choose, if she wants to use the zero-less method of picking like:
series: skip [-2 -1 1 2] 2 ; == [1 2]
pick-prop :series 1 ; == 1
pick-prop/back :series 1 ; == -1
or use zero and negative numbers. In this case the expressions:
pick :series n
pick/back :series n
are equivalent to
pick/back :series 1 - n
pick :series 1 - n
Regards
Ladislav