Re: stack/table overflows on storing complex scripts
Re: stack/table overflows on storing complex scripts
- Subject: Re: stack/table overflows on storing complex scripts
- From: "Arthur J. Knapp" <email@hidden>
- Date: Wed, 21 Aug 2002 18:29:54 -0400
>
Date: Wed, 21 Aug 2002 12:48:42 -0400
>
Subject: Re: stack/table overflows on storing complex scripts
>
From: "Arthur J. Knapp" <email@hidden>
>
> From: has
>
> Example: I've just implemented some new stack/queue objects that store
Of course, a normal list-based solution is also possible:
on newStack()
script Stack
property stackList : {}
on Push(v)
set stackList's beginning to v
end Push
on Pop()
try
set v to stackList's item 1
set stackList to stackList's rest
return v
on error
return missing value
end try
end Pop
end script
return Stack
end newStack
on newQueue()
script Queue
property queueList : {}
on Push(v)
set queueList's end to v
end Push
on Pop()
try
set v to queueList's item 1
set queueList to queueList's rest
return v
on error
return missing value
end try
end Pop
end script
return Queue
end newQueue
set s to newStack()
set q to newQueue()
s's Push(1) --> first in
s's Push(2)
s's Push(3)
s's Pop() --> 3
s's Pop() --> 2
s's Pop() --> 1, last out
q's Push(1) --> first in
q's Push(2)
q's Push(3)
q's Pop() --> 1, first out
q's Pop() --> 2
q's Pop() --> 3
s's Pop() --> missing value, empty stack
q's Pop() --> "" "" "" queue
{ Arthur J. Knapp, of <
http://www.STELLARViSIONs.com>
a r t h u r @ s t e l l a r v i s i o n s . c o m
}
_______________________________________________
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.