Created
December 15, 2014 04:01
-
-
Save ktnyt/467bc5f2c850a8a77598 to your computer and use it in GitHub Desktop.
Polish Notation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
print p([@ARGV]), "\n"; | |
sub p { | |
my $e = shift; | |
my $s = shift @{$e}; | |
return p($e) + p($e) if $s eq "+"; | |
return p($e) - p($e) if $s eq "-"; | |
return p($e) * p($e) if $s eq "*"; | |
return p($e) / p($e) if $s eq "/"; | |
return $s; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment