Re: Trimming down a list
Re: Trimming down a list
- Subject: Re: Trimming down a list
- From: Paul Berkowitz <email@hidden>
- Date: Thu, 11 Apr 2002 08:17:13 -0700
On 4/11/02 6:50 AM, "Arthur J Knapp" <email@hidden> wrote:
>
> Date: Wed, 10 Apr 2002 17:08:17 +0100
>
> Subject: Re: Trimming down a list
>
> From: Steve Thompson <email@hidden>
>
>
> on 10/4/02 4:22 pm, Paul Berkowitz at email@hidden wrote:
>
>
>
>> if thisItem is not in k then set end of k to thisItem
>
>
> I changed it to:
>
>
>
> if thisItem is not in k then set k to k & thisItem
>
>
> And it works. Is that a bug or does list not understand end of?
>
>
>
So you are saying that:
>
>
>> if thisItem is not in k then set end of k to thisItem
>
>
doesn't work?
>
>
Is your list a list of sublists?
It appears that that was indeed the case, which was never explained the
first time. From Steve's very last message:
>
>> {"An Item"} is in {{"An Item"},{"Another Item"}}
>
>>
>
>> And
>
>>
>
>> "An Item" is in {{"An Item"},{"Another Item"}}
>
>>
>
>> ... Both return false which confirms this which is the bit that I think is a
>
>> bug. A number of people including myself thought it would work so...
>
>>
>
> I wouldn't expect it to work so don't think it a bug :)
>
>
Why don't you expect this to work? "An Item" IS in {{"An Item"},{"Another
>
Item"}} - I can see it. Why can't AppleScript?
So that's the reason, as Arthur goes on to elucidate very clearly.
>
If so, there are additional
>
steps you want to take:
>
>
if {thisItem} is not in k then set end of k to thisItem
>
>
The ( {item} is in list ) syntax is nessesary for robust testing.
>
Bill Cheeseman's website has an explaination somewhere of why this
>
is:
>
>
<http://www.AppleScriptSourceBook.com/>
There's a succinct instruction about this in the AppleScript Language Guide,
but not a full explanation Bill's is excellent, as is Arthur's in hi final
message , which followed this one I'm replying to.
>
>
The "set end of list to item" should not need any modification,
>
(unless you are trying to "flatten" the sublists, which is what
>
happens when you say "set list to list & sublist").
>
>
>
P.S. Of course, by the time this email gets to the list server, Paul
>
Berkowitz will have already posted 15 new messages to the thread.
>
>
;-)
Nah, I live on the West Coast so I was sleeping. I'm rather glad you took
care of this, since i don't think I could have coped with the double-braces
explanation at 6:00 AM.
So, just to make sure you got to the point of Arthur's very clear
explanation of a complicated situation, if you're in fact looking for a
sub-item of a sublist of a list, you'll need to do:
if {{"An Item"}} is in {{"An Item"},{"Another Item"}}
and that will give you the speediest version, along with all the other
stuff. Andy is correct that 'count' won't make much difference over 'number
of items', but it doesn't hurt either. (One day you might have that command
itself within an outer loop of 10,000 iterations, and then it might make a
difference, I suppose.)
--
Paul Berkowitz
_______________________________________________
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.