[REBOL] Re: Accessing nested Blocks + search in blocks
From: g:santilli:tiscalinet:it at: 4-Nov-2000 20:55
Hello Joachim!
On 04-Nov-00, you wrote:
JT> By the way, is there a method to search (deep/recutsively)
JT> into block, not only at the first level? And accessing into
It's probably slow, but:
find-deep: func [block [any-block!] value /local res] [
forall block [
any [
if any-block? block/1 [
if res: find-deep block/1 :value [break/return res]
]
if block/1 = :value [break/return :block]
]
]
]
>> find-deep myblock 'one
== [one [1 2 3]]
>> find-deep myblock 3
== [3]
>> find-deep myblock 7
== [7 8 9]
Depending on your application, this might be speeded up using the
native FIND.
JT> blocks, like myblock/1/2/3 using indexes/variables and not
JT> direct references?
Did you mean something like this?
>> i: 1 j: 2 k: 3
== 3
>> myblock/:i/:j/:k
== 3
>> pick pick pick myblock i j k
== 3
Regards,
Gabriele.
--
Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer
Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/