aboutsummaryrefslogtreecommitdiff
path: root/challenge-095/deadmarshal/perl/Stack.pm
blob: b7f7432f91d6c8640f27affd5044ae6b1895f738 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package Stack;
use strict;
use warnings;
use List::Util;

sub new{
  my $class = ref($_[0]) || $_[0];
  my $self = bless [], $class;
}

sub push {
  my ($self, $item) = @_;
  CORE::push @$self, $item;
}

sub pop {
  my ($self) = @_;
  CORE::pop @$self;
}

sub top {
  my ($self) = @_;
  $self->[@$self - 1];
}

sub min {
  my ($self) = @_;
  List::Util::min @$self;
}

1;