----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, February 24, 2000 6:36 AM
Subject: [REBOL] select question


>
> I have a series with multiple identical entries, but different values:
>
> [ "book" "The Hobbit" "book" "The Stand" "candy" "Mars Bar" "candy"
"M&M" ]
>
> I want to search the series for each occurrence of say "book" and then
> evaluate it for a match.  How can I do this?  Or, is select perhaps not
the
> right hammer to beat this puzzle with?
>
> Brad Emerson
>
>

Hi Brad,

A couple of ideas...

db: [ "book" "The Hobbit" "book" "The Stand" "candy" "Mars Bar" "candy"
"M&M" ]

foreach [category item] db [
    if category = "book" [print item]
]

Or you could look at rearanging the way you store your data, so that items
are stored under
their categories.

db: [
    book ["The Hobbit" "The Stand"]
    candy ["Mars Bar" "M&M"]
]

foreach item db/book [print item]
foreach item db/candy [print item]

or
category: 'book
foreach item db/:category [print item]

Cheers

Allen K



Reply via email to