Re: Removing (or picking) items from list 1 via list 2?
Re: Removing (or picking) items from list 1 via list 2?
- Subject: Re: Removing (or picking) items from list 1 via list 2?
- From: Charles Arthur <email@hidden>
- Date: Wed, 24 Apr 2002 13:00:05 +0100
On Tue, 23 Apr 2002 23:37:53 +0200, Emmanuel <email@hidden>
wrote:
>
At 7:06 PM +0200 23/4/02, Charles Arthur wrote:
>
>
>
>Here's the problem, speed freaks.
>
>I have a list - list1 - which could get quite large - say, 400-500 items,
>
>all OS aliases.
>
>Meanwhile I also have list2 which will also have lots of aliases. Might
>
>easily be bigger than list1.
>
>I want to pick things randomly from list1 that aren't in list2, to create
>
>mywanteditem.
>
>
Not saying that the solutions proposed were not optimal, but personally I
>
would check the following proposition: build / update list3 as you build /
>
change list1. Ideally, new items would be inserted into list3 at a random
>
rank, so when "playing" list1 you would just pick list3's first item. There
>
is no need to empty list1, only list3 (set list3 to rest of list3). For the
>
purposes here, list1 is useless.
The problem though is that list1 is what I get presented with. It's
iTunes's playlist (a list of aliases).
OK, I'll really explain it. I'm making random playlists in iTunes
for MP3 players.
Take a big playlist - say the "library" playlist in iTunes. This is list1.
Take a smaller list - say of genres of music that you want to include (or
exclude; it's just a comparison you'll make).
My method is to take list1, randomly choose an item, and compare its
properties (eg size, genre) against the smaller "genrelist", and if it's OK
to use then add it to the new playlist you're making. That's fine for your
first item.
So now you want to "remove" that item from list1 (*curses* that
there's no such command in vanilla AS... is there? If there was then most
of these questions would disappear. Remember, no OSAX allowed!! Because
this is for distribution.)
My method in the early stage of this process is to add that
just-chosen item to list2. Also, if the item you tried failed in the
comparison (eg wrong genre) then also add it to list2, which is the "bad
list" of tracks you've either used or don't want to use.
This latter step means it's impossible to predict ahead of time
whether list2 is eventually going to be much smaller than list1. You might
be cherry-picking tracks; or you might have a supermarket shelf of them
from which you pick freely. In the former case, list2 will become big
compared to list1; in the latter, it'll stay small.
Anyway, repeat, and now compare the new random item you choose from list1
with all the items in list2. We might guess that for most of the time list2
will be considerably smaller than list1. (Though note cherry-picking vs
supermarket shelf comment.)
There also comes a stage though when you're approaching the limit of the
size of playlist you want to build, and so there aren't many tracks which
are small enough to choose. (Can't add a 20Mb track to 2Mb remaining
space.) At this point, it becomes really slow to hope that you'll randomly
pick tracks which are small enough from list1; you have to create a
"chosen" list of small-enough tracks. (Anyone care to guess when it's
efficient to make that shift? I've guessed when the number of small-enough
tracks is one-tenth of the whole playlist's contents. Perhaps instead a
comparison with the size of list2?)
So now one starts a different loop within the overall loop of creating the
playlist. Here, iTunes creates a "chosen" list1 from the given playlist
which contains tracks smaller than "remaining size". So list1 is now quite
small. (Perhaps 400 items, and reducing with each loop). But list2 might be
quite big by this time.
It's here that I thought it's more efficient to "clean" list1 via list2 to
create list3. One also has to do subtle things to make sure that the
process actually completes rather than looping forever.
So to return to Emmanuel's answer, list1 is very much not useless. It's the
source of the information. And I don't follow how I would create list3 and
add items "at a random rank" to it. And I wonder whether it's really the
best answer, and what the best (=quickest) algorithm is here.
Damn lists.
Charles
----------------------------
http://www.ukclimbing.com : 1100+ British crags, 350+ British climbing
walls - searchable by distance and anything else you care to think of -
with weather forecasts for every one, plus maps, articles, news and
features. And there's even a cool shop attached.
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.