• 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: Snippet to remove an item from a list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Snippet to remove an item from a list


  • Subject: Re: Snippet to remove an item from a list
  • From: Arthur J Knapp <email@hidden>
  • Date: Tue, 10 Jul 2001 09:51:42 -0400

> Subject: Re: Snippet to remove an item from a list
> Date: Mon, 9 Jul 2001 08:38:04 -0700
> From: Michelle Steiner <email@hidden>

> On 7/9/01 7:24 AM, Arthur J Knapp <email@hidden> wrote:
>> Here is the more traditional AppleScript technique:

> Alternatively (slightly modifying Arthur's script):
>
> on DeleteAt(lst, x)
> tell the lst
> if (x = 1) then
> return the rest
> else if (x = the length) then
> return items 1 thru -2
> else
> return (items 1 thru (x - 1)) & ,
> (items (x + 1) thru -1)
> end if
> end tell
> end DeleteAt

Allow me to be even more alternative:

on DeleteAt(lst, x)
tell lst to if x = 1 then
rest
else if (x = length) then
items 1 thru -2
else
(items 1 thru (x - 1)) & (items (x + 1) thru -1)
end if
end DeleteAt


Here are some new creations:

on InsertAt(lst, x, val)
tell lst to if x = 1 then
{val} & it
else if x > length then
it & {val}
else
items 1 thru (x - 1) & {val} & items x thru -1
end if
end InsertAt

on IndexOf(lst, itm)
set x to 1
tell no & lst to if {itm} is in it then repeat until item x = itm
set x to x + 1
end repeat
x - 1
end IndexOf



Arthur J. Knapp
http://www.stellarvisions.com
mailto:email@hidden

Hey, check out:
http://www.LateNightSW.com


  • Follow-Ups:
    • Re: Snippet to remove an item from a list
      • From: Paul Berkowitz <email@hidden>
    • Re: Snippet to remove an item from a list
      • From: Bryan <email@hidden>
    • Save (Quicktime Movie) as JPEG
      • From: Simon Forster <email@hidden>
  • Prev by Date: Re: count of items in a reference to a list
  • Next by Date: scriptable installers
  • Previous by thread: Re: Snippet to remove an item from a list
  • Next by thread: Save (Quicktime Movie) as JPEG
  • Index(es):
    • Date
    • Thread