Index: apps/scripts/stack.tcl =================================================================== diff -u --- apps/scripts/stack.tcl (revision 0) +++ apps/scripts/stack.tcl (revision 5c200556d0edbe7ef71130caf11c6d04fb0acf0e) @@ -0,0 +1,21 @@ +package req next + +nx::Class create stack { + :method init {} {set :things {}} + :public method push {thing} { + set :things [linsert ${:things} 0 $thing] + return $thing + } + :public method pop {} { + set top [lindex ${:things} 0] + set :things [lrange ${:things} 1 end] + return $top + } +} + +stack create s1 +puts [s1 push 1] +puts [s1 push 2] +puts [s1 pop] +puts [s1 pop] +puts [s1 pop] \ No newline at end of file