[REBOL] Re: Finding a value in a series?
From: gjones05:mail:orion at: 21-May-2001 12:03
From: "Charles Wardell"
> How do you do a find on the first element in a series of blocks?
>
> >> probe blk
> [
> [1 a b]
> [2 c d]
> [3 e f]
> ]
>
> I want to search for the value 2 and assign the remainder to a
variable. I
> then want to delete the record in the series?
Hi, Charles,
As usual, Joel makes great points about what a person "wants" to do
versus really "should" do.
;-)
But if you are looking for a down and dirty "one liner"-type script in
order to understand how nested blocks work, then consider:
a-blk: [
[1 a b]
[2 c d]
[3 e f]
]
forskip a-blk 1 [if find a-blk/1 2 [e: a-blk/1/2 f: a-blk/1/3 remove
a-blk]]
a-blk: head a-blk ;forskip leaves block index at tail, need to reset
probe a-blk
print [e f]
Basically, 'find does not (currently) work "deep", meaning on nested
blocks without some form of iterating through the primary block.
--Scott Jones