Hi,
I remember the very ooold days of Rebol, it was some 1997 and Rebol existed
just in some form of Alpha prerelease featuring very little of its current
set of datatypes :-) I implemented function called 'extract, doing something
similar ....
... it is interesting to see someone else sees need for some kind of
functions, allowing us to work with nested structures. Everything Rebol
interpreted is just ... well ... interpreted ...
I suggested some kind of find/deep functionality, returning path to the
element. I mentioned it to Carl on Express Conference, and he expressed the
opinion Rebol's 'find function is overly compex. So I suggested calling it
'locate, or something like that ...
->> locate address-book 'last
->> 1/2/2 ; or [1 2 2]
I am not sure if it could be appliable upon some more complex cases, e.g.
distinguishing literals lookup, words look-up, string and other datatypes
lookup, what about several occurances of the same value we are looking for?
just theoretically, it could:
1) treat even complex block nested structured as "flat" ones, 1 dimmensional
ones ...
2) let's say we want to perform some kind of lookup that way thru
main-face/pane containing other faces (and their panes etc, simply nested
displays .... there is danger of cross-reference though ...
... as for cross-references, rebol halts probing VID stuff too much. ...
just as an example try:
view layout [btn: button "OK" [unview]]
probe btn
... and you will see not only btn face got probed ...
Sorry for being off-topic, but ... it just came to my mind :-)
-pekr-
----- Original Message -----
From: "Mike Yaunish" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, April 27, 2001 8:53 PM
Subject: [REBOL] Setting variable in complex paths
> I have been working with complex paths in REBOL because I just love how
> easy they are
> to work with - however I have had some problems setting variables within
a
> complex
> path. I think I have a fairly good solution, but know if I expose it to
the
> light of other REBOLers
> it can be even better. I have called this function "complex-set".
>
>
> complex-set: func ["Sets a complex path (from a block of literal words) to
> a specified value"
> complex-path [block!] "Block of literal and normal
> words that describe the complex path"
> value [any-type!] "Value to be set"
> ][
> either lit-word? last complex-path [
> prefix-path: copy/part complex-path ((length? complex-path) - 1 )
> the-path: to-path reduce prefix-path
> the-field: to-lit-word last complex-path
> either ( found? find the-path the-field ) [
> do bind reduce [to-set-path reduce complex-path value] 'do
> ][ ; field doesn't already exist so create it
> append/only the-path the-field
> append/only the-path value
> ]
> ][
> do bind reduce [to-set-path reduce complex-path value] 'do
> ]
> ]
>
> address-book: [ [name [first "Joe" last "Blow" ] address [city "Goosebay"
> province "Labrador"]]
> [name [first "Tim" last "Taylor" middle "Lee"] address [city
> "Calgary" province "Alberta"]]
> ]
>
> >>index: 2
> >>new-name: "Tiny"
> >>complex-set [ 'address-book index 'name 'middle ] new-name
>
> "complex-set" also accomodates the creation of fields within a path.
> For example;
>
> >>complex-set [ 'address-book 1 'name 'middle ] "Lincoln"
> >>complex-set [ 'address-book 2 'address 'zip ] 90210
>
> >> print mold address-book
> [[name [first "Joe" last "Blow" middle "Lincoln"] address [city "Goosebay"
> province "Labrador"]]
> [name [first "Tiny" last "Taylor" middle "Tiny"] address [city
> "Calgary" province "Alberta" zip 90210]]
> ]
>
> There are some minor limitations - but it works great for REBOL named
fields.
> Any comments would be appreciated.
>
>
>
>
> Mike Yaunish
> [EMAIL PROTECTED]
>
> --
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the
> subject, without the quotes.
--
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the
subject, without the quotes.