• 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: (beep) as string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (beep) as string


  • Subject: Re: (beep) as string
  • From: Arthur Knapp <email@hidden>
  • Date: Thu, 20 Nov 2003 13:15:27 -0500

From: Shane Stanley <email@hidden>
Subject: Re: (beep) as string
Date: Thu, 20 Nov 2003 09:33:41 +1100

On Nov 20, 2003, at 4:58 AM, Arthur Knapp wrote:
Off the top of my head, I can't think of any AppleScript purpose for
this.

We'll wait a day or so.

;-)

OK, let me know if anyone finds a useful purpose for this:

property nil : missing value

script RoundRobinCLASS

on GetValue() --> current node's value
if (my siz = 0) then return nil
return my cur's v
end GetValue

on SetValue(v) --> change node's value
if (my siz = 0) then return nil -- ??? throw error ???
set my cur's v to v
end SetValue

on NewValue(v) -- inserts a node, making it the current node
set node to {v:v, l:nil, r:nil}
if (my siz = 0) then
set my cur to node
set my cur's l to node
set my cur's r to node
else
set node's l to my cur
set node's r to my cur's r
set my cur's r to node
set my cur to node
end if
set my siz to (my siz) + 1
return result --> for convenience
end NewValue

on PopValue() --> deletes the current node, returning its value
if (my siz = 0) then return nil
set v to my cur's v
if (my siz = 1) then
set my cur to nil
else
set my cur's l's r to my cur's r
set my cur's r's l to my cur's l
set my cur to my cur's r
end if
set my siz to (my siz) - 1
return v
end PopValue

on NextValue() --> next node's value, makes the next node the current node
if (my siz = 0) then return nil
set my cur to my cur's r
return my cur's v
end NextValue

on PrevValue()
if (my siz = 0) then return nil
set my cur to my cur's l
return my cur's v
end PrevValue

on ValueCount()
return my siz
end ValueCount

end script

on newRoundRobin(a) --> optional initial list

script RoundRobin
property parent : RoundRobinCLASS
property cur : nil
property siz : 0
end script

if (a's class = list) then repeat with i from 1 to a's length
RoundRobin's NewNode(a's item i)
end repeat

return RoundRobin

end newRoundRobin

It works and all, but it's slower than a normal list-based solution would be.

{ Arthur J. Knapp;
<mailto:email@hidden>;

What...? Oh...!
}
_______________________________________________
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.

  • Prev by Date: re: Frustrated novice wants to paste the clipboard
  • Next by Date: Re: Inconsistent results from Finder and System Events
  • Previous by thread: Re: (beep) as string
  • Next by thread: Re: (beep) as string
  • Index(es):
    • Date
    • Thread