Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
39
Task/Stack/AutoHotkey/stack.ahk
Normal file
39
Task/Stack/AutoHotkey/stack.ahk
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
msgbox % stack("push", 4)
|
||||
msgbox % stack("push", 5)
|
||||
msgbox % stack("peek")
|
||||
msgbox % stack("pop")
|
||||
msgbox % stack("peek")
|
||||
msgbox % stack("empty")
|
||||
msgbox % stack("pop")
|
||||
msgbox % stack("empty")
|
||||
return
|
||||
|
||||
stack(command, value = 0)
|
||||
{
|
||||
static
|
||||
if !pointer
|
||||
pointer = 10000
|
||||
if (command = "push")
|
||||
{
|
||||
_p%pointer% := value
|
||||
pointer -= 1
|
||||
return value
|
||||
}
|
||||
if (command = "pop")
|
||||
{
|
||||
pointer += 1
|
||||
return _p%pointer%
|
||||
}
|
||||
if (command = "peek")
|
||||
{
|
||||
next := pointer + 1
|
||||
return _p%next%
|
||||
}
|
||||
if (command = "empty")
|
||||
{
|
||||
if (pointer == 10000)
|
||||
return "empty"
|
||||
else
|
||||
return 0
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue