[REBOL] Find cant find reference to block. Re:(3)

2000-07-15 Thread bhandley

Thankyou Gabriele,

That by itself is useful to know. But, it still is different to what I was
asking.
My code was attempting to find an empty block. But not just any empty block
it was a particular empty block. But find doesn't distinguish between
particular empty blocks they look the same! Which I guess is reasonable.

Yet I can store multiple different empty blocks inside another block such
that they behave as references to blocks. Which is really handy. For example
I used this to create bookmarks in some HTML I was creating. E.g

my-html: []
append/only my-html my-bookmark: copy []
append my-html [  ]
append my-bookmark "How to fill in after the fact with Rebol blocks"
print my-html

But I just can't use find to find those references

my-html: []
append/only my-html my-bookmark-1: copy []
append my-html []
append/only my-html my-bookmark-2: copy []
append my-html [ ]

What is the index position of the block referred to by my-bookmark-2 in
my-html?
>> index? find/only my-html my-bookmark-2
== 4

Nope it got it wrong, the answer I wanted was 6.

But if I now do this
append my-bookmark-2 "Fill in the body"

and try the same question - it gets it right
>> index? find/only my-html my-bookmark-2
== 6

Brett.

- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, July 15, 2000 10:55 PM
Subject: [REBOL] Re: Find cant find reference to block. Re:


> Hello [EMAIL PROTECTED]!
>
> On 14-Lug-00, you wrote:
>
>  G>>> find list select list 'a ; no good find can't find the
>  G>>> reference to the
>  G> block
>
> Hope this clears things up:
>
> >> find [a b c d e f g e g f h i j] [e g f]
> == [e g f h i j]
> >> find/only [a b c d e f g e g f h i j] [e g f]
> == none
> >> find/only [[a] [b]] [a]
> == [[a] [b]]
> >> find/only [[a] [b]] [b]
> == [[b]]
>
> So:
>
> >> blk: [a ["a"] b ["b"]]
> == [a ["a"] b ["b"]]
> >> select blk 'a
> == ["a"]
> >> find/only blk select blk 'a
> == [["a"] b ["b"]]
>
> But notice that that is the same as:
>
> >> next find blk 'a
> == [["a"] b ["b"]]
>
> which does one search only.
>
> Regards,
> Gabriele.
> --
> Gabriele Santilli <[EMAIL PROTECTED]> - Amigan - REBOL programmer
> Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/
>




[REBOL] Find cant find reference to block. Re:(3)

2000-07-15 Thread lmecir

Hi,


> Thanks for the responses. But
>
> > >> find list reduce [select list 'a]
> > == [["a" "a-test"] b ["b"]]
> >
> > -Galt
> >
> >
>
> Galt, that looked like what I wanted but on further
investigation does'nt
> seem to do what I want. It find the value that is the result of
the reduce,
> not the reference to the block itself - which is want I want.
>
> I've gotta confess to making a bad example as the basis of my
query too.
>
> A better example would be this:
>
> lookup: []
> reverse_lookup: []
>
> entry: func[x] [
> e: copy []  ; Note that e here is global - needed below.
> append lookup x append/only lookup e
> append/only reverse_lookup e append reverse_lookup x
> ]
>
> entry "a"
> entry "b"
> entry "c"
>
> ; Show that my lookup blocks contain references to blocks.
> append select lookup "b" "added to the series" ; Works well adds
to both
> probe lookup ; it appears here
> probe reverse_lookup ; and here - now that's useful.
>
> ; But can I find the reference to the block that e refers to in
the lookup
> list?
> probe find reverse_lookup :e ; No is the answer
>
> ; ---
>
> So the upshot is. I seem to be able to store references to
blocks in other
> blocks. Thus allowing using a pointer concept. But I cannot find
an operator
> which can find the reference, as opposed to, finding the thing
it refers to.
>
> Correct?
>
> Brett.
>

>> probe find/only reverse_lookup :e ; The answer:
[[] "a" ["added to the series"] "b" [] "c"]
== [[] "a" ["added to the series"] "b" [] "c"]