[REBOL] Re: On ordinal and cardinal numbers...
From: lmecir:mbox:vol:cz at: 7-Jul-2001 12:01
Hi all,
is there a chance that Carl gets something more people can agree upon? My
idea is to have something like these:
1) SKP function, a zero-based linear skip. The word "linear" means, that it
would behave like SKIP, if skipping into the series, which means, that (skp
block n) shall produce the same result as (skip block n) for 0<= n <(length? block).
For greater offsets it should produce different results.
E.g. (skp tail block 1) should produce the same result as (append block 1
result: skip tail block remove back tail block result). Similarly, for
negative offsets, if skipping into the block, the result should be the same
as the result of SKIP. For lower offsets it should behave differently than
SKIP, see below.
2) SKP? function, that will be a counterpart of SKP, i.e. for any block
BLOCK the following identity would hold: ((skp? head block) = 0) and for any
integer I the following identity would hold: ((skp? skp head block i) = i).
3) a PEK function, that should work (in essence) as follows:
pek: function [
[catch]
block
offset [integer!]
/default
handler [block!]
] [err] [
if error? err: try [
return first skp :block offset
] [
either default [
return do handler
] [
throw err
]
]
]
4) a POK function, that should work (in essence) as follows:
pok: function [
[catch]
block
offset [integer!]
value [any-type!]
/default
handler [block!]
] [err pos] [
if error? err: try [
pos: skp :block offset
return change pos get/any 'value
] [
either default [
return do handler
] [
throw err
]
]
]
Regards
Ladislav