• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Removing item from list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing item from list


  • Subject: Re: Removing item from list
  • From: Deivy Petrescu <email@hidden>
  • Date: Sat, 15 Sep 2001 13:38:56 -0400

At 1:18 PM -0400 9/15/01, Bryan wrote:
set x to {"a", "b", "c", "d"}
set z to {}
repeat with y in x
if y is not "c" then set z to z & y
end repeat
set x to z


I use Satimage OSAX Suppress Item:

set x to {"a", "b", "c", "d"}
suppress item "c" from x

I don't know if its any faster.

Saving characters in long scripts is important if you want to be able to
run an
event log debugger (if you don't have Script Debugger (which I don't))
due to
the 32k limit.

Bryan Kaufman


It is very fast.
Instead of Satimage osax one can use the "Satimage sort".
That is an adaptation of the sort routine by E. Levy from Satimage.
There is one major difference besides time, this one eliminates all occurrences of "c".

See the example below

____
set lista to {}
repeat with l from 1 to 20
repeat with z from 1 to 20
set end of lista to z
end repeat
end repeat



--suppress item 15 from lista


--set newlista to removeitem(lista, 15)
--newlista

on removeitem(lista, ditem)
set removedlista to {}
repeat with l in lista
if contents of l  ditem then set removedlista to removedlista & l
end repeat
return removedlista
end removeitem

____
One can make minor changes to eliminate only one instance of the item.

Regards


Deivy Petrescu
http://www.dicas.com


References: 
 >Removing item from list (From: Irwin Poche <email@hidden>)
 >Re: Removing item from list (From: Bryan <email@hidden>)

  • Prev by Date: Re: problem in script
  • Next by Date: Re: Scriptable Text Editor
  • Previous by thread: Re: Removing item from list
  • Next by thread: Re: Removing item from list
  • Index(es):
    • Date
    • Thread