<commit_before>package Artemis::Plugin::Calc;
use Math::Complex;
use Math::Trig;
sub new{
	my $class =shift;
	return bless([],$class);
};

sub input{
	my $self = shift;
	my($conn,$msg) = @_;
	if($msg->text =~ /^calc (.*)$/){
		my @stack = ();
		my $memory = 0;
		my @ops = split ' ',$1;
		for(@ops){
			push @stack,oct($_) and next if /^0[0-7]+?$/;
			push @stack,oct($_) and next if /^0b[01]+?$/;
			push @stack,oct($_) and next if /^0x?[0-9a-f]+?$/;
			push @stack,0+$_ and next if /^-?\d+(\.\d+)?$/;
			$_=lc$_;
			if(exists($op{$_})){
				undef $@;
				eval{$op{$_}->(\@stack,\$memory)} if ref $op{$_} eq "CODE";
				return $conn->message($msg->to,"Error: $@") if $@;
				push @stack, $op{$_} if ref $op{$_} eq "";
			}
		}
		$conn->message($msg->to,"Returned ".join(",",@stack));
	}
};

%op=(
# section 1: binops
'+' => sub{$_[0][-2] += pop @{$_[0]}},
'-' => sub{$_[0][-2] -= pop @{$_[0]}},
'*' => sub{$_[0][-2] *= pop @{$_[0]}},<commit_msg>Fixed a bug in Calc.pm and added dice<commit_after>package Artemis::Plugin::Calc;
use Math::Complex;
use Math::Trig;
sub new{
	my $class =shift;
	return bless([],$class);
};

sub input{
	my $self = shift;
	my($conn,$msg) = @_;
	if($msg->text =~ /^calc (.*)$/){
		my @stack = ();
		my $memory = 0;
		my @ops = split ' ',$1;
		for(@ops){
			push @stack,oct($_) and next if /^0[0-7]+?$/;
			push @stack,oct($_) and next if /^0b[01]+?$/;
			push @stack,oct($_) and next if /^0x?[0-9a-f]+?$/i;
			if(my@x=/^(\d+)d(\d+)$/){push@stack,$x[1]?int(rand$x[1])+1:0 while$x[0]--}
			push @stack,0+$_ and next if /^-?\d+(\.\d+)?$/;
			$_=lc$_;
			if(exists($op{$_})){
				undef $@;
				eval{$op{$_}->(\@stack,\$memory)} if ref $op{$_} eq "CODE";
				return $conn->message($msg->to,"Error: $@") if $@;
				push @stack, $op{$_} if ref $op{$_} eq "";
			}
		}
		$conn->message($msg->to,"Returned ".join(",",@stack));
	}
};

%op=(
# section 1: binops
'+' => sub{$_[0][-2] += pop @{$_[0]}},
'-' => sub{$_[0][-2] -= pop @{$_[0]}},
'*' => sub{$_[0][-2] *= pop @{$_[0]}},
{'fraction_non_alphanumeric': 0.3233082706766917, 'fraction_numerical': 0.02456140350877193, 'mean_word_length': 3.5990783410138247, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4763408', 'n_tokens_mistral': 998, 'n_tokens_neox': 908, 'n_words': 186}