[rebol [title: "funny search"]
MyStructure: [
is-is? ["US" ["USA" "English" "Spanish"]]
is-is? ["DE" ["Germany" "German"]]
is-it? ["NZ" ["New Zealand" "English"]]
]
look-for: "DE"
found: none
is-it?: func [block] [
if look-for = first block [
found: block
]
]
do MyStructure
? found
;-)
]
>I've been doing the following with a similar problem:
>
>
>MyStructure: [
> ["US" ["USA" "English" "Spanish"] ]
> ["DE" ["Germany" "German"] ]
> ["NZ" ["New Zealand" "English"] ]
> ]
>
>search: func [search-term [string!]][
> foreach item MyStructure [
> if find first item search-term [
> return second item
> ]
> ]
>]
>
>Example:
>
> >> search "NZ"
>== ["New Zealand" "English"]
>
>>> search "DE"
>== ["Germany" "German"]
>
>I hope this is what you were asking for.
>
>--- [EMAIL PROTECTED] wrote:
>> Can you guys help me on this one?
>>
>> I've got a structure like this:
>>
>> MyStructure: [ [key1 data1] [key2 data2] [key3
>> data3] ... ]
>>
>> where each Key is a single string, but the Data is
>> another block.
>>
>> Example:
>>
>> MyStructure: [
>> ["US" ["USA" "English" "Spanish"] ]
>> ["DE" ["Germany" "German"] ]
>> ["NZ" ["New Zealand" "English"] ]
>> ]
>>
>>
>> I can't find any way to use Find to find me a given
>> key:
>>
>> >> find MyStructure "US"
>> == none
>> >> find MyStructure ["US"]
>> == none
>>
>> Is there something I can do with Find?
>>
>> I don't want to change the structure to
>>
>> MyStructure: [ key1 [data1] key2 [data2] key3
>> [data3] ... ]
>>
>> which is Find-able, but isn't SORT-able,--or at
>> least not by me.
>>
>> Thanks,
>> Colin.
>> --
>> To unsubscribe from this list, please send an email
>> to
>> [EMAIL PROTECTED] with "unsubscribe" in the
>> subject, without the quotes.
>>
>
>
>__________________________________________________
>Do You Yahoo!?
>Get email at your own domain with Yahoo! Mail.
>http://personal.mail.yahoo.com/
>--
>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.