8/6/2012 - 5:27 PM

minStack @!.pl

#todo how to use multi?
class Minstack {

    has @!stack;
    has @!min;

    method mpush($item) {
	push @.stack, $item;  
	if @.min==0 or @.min[*-1] > $item {
	    push @.min, $item;

    method mpop() {	
	my $item=pop @.stack;
	if $item == @.min[*-1] {
	    pop @.min;
	return $item;

    method mmin() {


my $min=Minstack.new;
say $min.stack; 
say $min.min; 
say $min.mmin();
say $min.mpop();
say $min.mmin();

=begin comment

No such method 'stack' for invocant of type 'Minstack'
  in method mpush at Minstack02.pl:9
  in block <anon> at Minstack02.pl:32

=end comment