Filtering array vs plain list
dick.kriesel at mail.com
Sat Feb 2 02:42:30 CST 2008
On 2/1/08 8:35 PM, "Shari" <shari at gypsyware.com> wrote:
> I've never worked with intersecting arrays, so please pardon the questions.
Actually it's just intersecting lists of values that come from different
arrays. Use-rev pardons almost all questions.
> If I understand your example, I'd have something like this:
> birthYear = John Jones,Billy Bob,Mary Lou,Manny Mack,Barbie Doll
> birthYear = Ellie May,Carrie Ann,Andy Ant,Donna Mills,Jackie O
> baseballTeam[Red Sox] = Billy Bob,Manny Mack
> baseballTeam[White Sox] = Barbie Doll,Ellie May
Yes, but you wouldn't want to duplicate everyone's name in 300 places.
Instead you could use the "identifier unique to each individual" you
> This would produce about 300 arrays. The  keys would be virtually
> unlimited. There might be a couple hundred birthYears for example.
You can use vastly more arrays and keys in Rev than you'll need.
> If I wanted to get all census data for Billy Bob, I'd do a repeat
> loop for each key of each of the 300 arrays to get all info
> pertaining to Billy Bob? I had not thought of that approach. It's
Mercy, no. What's fast is the kind of querying you mentioned: retrieving
based on multiple filters. To make it fast to get everything about Billy
Bob, your app would do some double-entry bookkeeping, maintaining arrays
personName = "Billy Bob"
birthyear = 1982
or like this, based on a design that uses an array for each person:
person_3258["name"]= "Billy Bob"
person_3258["birthYear"] = 1982
or like this, based on a design that uses a card for each person:
person["name"] of card 123 = "Billy Bob"
person["birthYear"] of card 123 = 1982
> To get a list of all Red Sox fans born in 1976, I'd just need to
> intersect the two array/key combos?
Intersecting the values you get from retrieving each array/key combo gives
you the identifiers for all the people who match all your selection
criteria, as many as you care to specify.
> Looking for all data on Billy Bob will happen more frequently than
> looking for all Red Sox fans born in 1976. And it will be common to
> delete Billy Bob from all arrays, or add Billie Jean. Most of the
> time the primary reference would be to Billy Bob, such as "What is
> Billy Bob's baseball team?" Does that change it?
That enhancement to the problem definition motivates the double-entry
> Note that this is not for a database, but for a game where I need to
> track thousands of people each having about 300 pieces of info
> defining them, the defining info will change constantly, and changes
> need to be instantaneous.
Noted. Still, you could use a database management system in your solution,
even though Rev makes it appealing to roll your own. Many threads have
addressed the relative merits of the alternatives. If you have more
questions about rolling your own, I'd be glad to try answering.
More information about the use-livecode