File tree Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -26,18 +26,18 @@ function Stack.new()
2626end
2727
2828-- Check if the stack is empty
29- function Stack :IsEmpty ()
29+ function Stack :isEmpty ()
3030 return # self ._stack == 0
3131end
3232
3333-- Put a new value onto the stack
34- function Stack :Push (value )
34+ function Stack :push (value )
3535 table.insert (self ._stack , value )
3636end
3737
3838-- Take a value off the stack
39- function Stack :Pop ()
40- if self :IsEmpty () then
39+ function Stack :pop ()
40+ if self :isEmpty () then
4141 return nil
4242 end
4343
@@ -57,21 +57,21 @@ local s = Stack.new()
5757
5858-- Change the stack Resulting stack Output
5959
60- s :Push (1 ) -- {1}
60+ s :push (1 ) -- {1}
6161
62- s :Push (5 ) -- {1, 5}
62+ s :push (5 ) -- {1, 5}
6363
64- s :Push (10 ) -- {1, 5, 10}
64+ s :push (10 ) -- {1, 5, 10}
6565
66- print (s :Pop ()) -- {1, 5} 10
66+ print (s :pop ()) -- {1, 5} 10
6767
68- print (s :Pop ()) -- {1} 5
68+ print (s :pop ()) -- {1} 5
6969
70- s :Push (20 ) -- {1, 20}
70+ s :push (20 ) -- {1, 20}
7171
72- print (s :Pop ()) -- {1} 20
72+ print (s :pop ()) -- {1} 20
7373
74- print (s :Pop ()) -- {} 1
74+ print (s :pop ()) -- {} 1
7575```
7676
7777<Alert severity =" warning " >
You can’t perform that action at this time.
0 commit comments