catch pom again!
#!perl -p
y/) /
/d;$a.=/\d/?!push
o,$_:/[^(0]/+/[*\/]/&&do{push o,$/while($/=chop$a)=~//;$/.$_}x/./for/(?
|
ahh, today rate is done
#!perl -p
y/) /
/d;$a.=/\d/?!push
o,$_:/\(/?0:do{push
o,$/while$/=chop$a,/[*\/]/?$/=~//:$/;$/.$_}x/./for/(?
|
#!perl -p
y/) /
/d;$a.=/\d/?!push
o,$_:/\(/?0:do{push
o,$/while$/=chop$a,/\*|\//?$/=~//:$/;"$/$_"x/./}for/(?
|
hmm
#!perl -p
y/) /
/d;/\d/?push
o,$_:/\(/?$a.=0:do{push
o,$/while$/=chop$a,/\*|\//?$/=~//:$/;$a.="$/$_"x/./}for/(?
|
outrun pom at tie again!
#!perl -p
y/) /
/d;/\d/?push
o,$_:/\(/?$a.=0:do{push
o,$/while$/=chop$a,/\*|\//?$/=~//:$/;/
/
or$a.=$/.$_}for/(?
|
damn, this looks like the limit for this algorithm, and i wonder what pom will answer?
#!perl -p
y/ //d;/\(/?$#a++:/\d/?push
o,$_:do{push
o,$,while$,=pop
a,/[*\/]/?$,=~//:$,;/\)/||push
a,$,,$_}for/(?
|
and yet another way how to kill the cat. fast.
Unfortunaly, it fails the test with '1 - -\t2'
#!perl -p
/\(/?push@;,0:/\d/?push@o,$_:do{push@o,pop@;while/\*|\//?$;[-1]=~//:$;[-1];/\)/?pop@;:push@;,$_}for/(?
|
looks like my previous attempt failed because i misunderstood 'negative' numbers.
#!perl -p
s/\s//g;/\(/?$#:++:/\d/?push
o,$_:do{push
o,pop@:while/[*\/]$/?"@:"=~//:$:[-1];/\)/?$#:--:push@:,$_}for/(?
|
#!perl -pi<([^>]+)>
y/ //d;s/(?/g;s/.*/($&)/;1while
s#\(([^()]+)\)#$_=$1;for$i('*/','+-'){s/$^I([$i])$^I/<$1 $3 $2>/&&redo}$_#e;y/<>//d
|
hmm, artistic or unortodox? at least it's platform dependant (needs s/'/#/g for windows). and speed is not my fault, it's Deparse's! :)
too slow and platform dependant .. even arthistic / unorthodox need to pass the judge :)
#!perl -p
s/\d+/\$$&/g;s/-/ -/g;close STDERR;$_=`$^X -MO=Deparse,-p -e '$_'`;
$q=qr/\(((??{$q})|-?\$\d+)( .)?( (??{$q})| -?\$\d+)?\)/;
1while s/$q/$1$3$2/;y/$;//d
|
who said dead horse? unfortunately changing ${$_[0]} to $${&w} doesn't work
#!perl -pl
BEGIN{@{integer,binary}=(w)x2;sub
w{bless\$_[0]}use
overload'""',sub{${$_[0]}},neg,sub{w"-$_[0]"};for
my$i(qw(+ - * /)){*{"($i"}=sub{w"@_$i"}}$=16e4}s/-/
-/g;$_=eval
|
sorry, i missed last stroke. mostly complete now.
#!perl -pl
BEGIN{sub
w{bless\$_[0]}use
overload
neg,sub{w"-$_[0]"},'""',sub{${$_[0]}};
for
my$i(qw(+ - * /)){*{"($i"}=sub{w"@_$i"}}@{integer,binary}=(\&w)x2;$=16e4}s/-/
-/g;$_=eval
|
*twitch*
#!perl -pl
BEGIN{sub
w{bless\$_[0]}use
overload
neg,sub{w"-$_[0]"},'""',sub{${$_[0]}};
for
my$i(qw(+ - * /)){*{"($i"}=sub{w"@_$i"}}@{integer,binary}=(\&w)x2;$=152e3}s/-/
-/g;$_=eval
|
is it shorterst overload?
#!perl -pl
BEGIN{sub
w{bless\$_[0]}use
overload
neg,sub{w"-$_[0]"},'""',sub{${$_[0]}};
for
my$i(qw(+ - * /)){*{"($i"}=sub{w"@_$i"}}@{integer,binary}=(\&w)x2;$|=151552}s/-/
-/g;$_=eval
|
abuse of perl
hmm .. another (ab)use of overload
#!perl -pl
BEGIN{$OVERLOAD{d}++;*{'()'}=sub{};eval"*{'($_'}=sub{bless\\\"\@_$_\",main}"for
qw(+ - * /);*{'(neg'}=sub{bless\"-$_[0]",main};*{'(""'}=sub{${$_[0]}};${integer}=${binary}=sub{bless\$_[0],main};$|=151552}s/--/-
-/;$_=eval
|
this B thing crashes too often
Failed with this message : Can't locate object method "padix" via package "B::SVOP" (perhaps you forgot to load "B::SVOP"?)
#!perl -p
use B;s/-/
-/g;s/\d+/\$$&/g;
for($x=($y=B::svref_2object(eval"sub{$_}"))->START,
@v=($y->PADLIST->ARRAY)[1]->ARRAY;$_=($x=$x->next)->name,!/ea/;){
push@a,/n/?-pop@a:/g/?@v[$x->padix]->NAME:/e/?'/':/y/?'*':/s/?'-':'+'
}$_="@a
"
|