Skip to main content
added 142 characters in body
Source Link
Ton Hospel
  • 15k
  • 1
  • 23
  • 45

Perl, 64 53 bytes

Include +1 for -p

perl -pe 's%([*-/])(([\d.]+|(?0))\1(?3))\1%($2)%&&redo;$_=eval' <<< "/4/-3-/1/2/-/" 

Accidentally also implements , (throws away the first argument) and sometimes . (append the arguments together). . doesn't work very reliable though since it interferes with decimal point both at the parsing level and at the evaluation level

Perl, 64 53 bytes

Include +1 for -p

perl -pe 's%([*-/])(([\d.]+|(?0))\1(?3))\1%($2)%&&redo;$_=eval' <<< "/4/-3-/1/2/-/" 

Accidentally also implements , (throws away the first argument) and . (append the arguments together)

Perl, 64 53 bytes

Include +1 for -p

perl -pe 's%([*-/])(([\d.]+|(?0))\1(?3))\1%($2)%&&redo;$_=eval' <<< "/4/-3-/1/2/-/" 

Accidentally also implements , (throws away the first argument) and sometimes . (append the arguments together). . doesn't work very reliable though since it interferes with decimal point both at the parsing level and at the evaluation level

deleted 21 characters in body
Source Link
Ton Hospel
  • 15k
  • 1
  • 23
  • 45

Perl, 6464 53 bytes

Include +1 for -p

perl -pe 's%^('s%([*-/]+])(([\d.]+|(?10)|\d+)\2(\1(?3))\2)$%\1%( $3 $2 $4 )%m&&redo;$_=eval'%&&redo;$_=eval' <<< "/4/-3-/1/2/-/" 

Accidentally also implements , (throws away the first argument) and . (append the arguments together)

Perl, 64 bytes

Include +1 for -p

perl -pe 's%^(([*-/]+)((?1)|\d+)\2((?3))\2)$%( $3 $2 $4 )%m&&redo;$_=eval' <<< "/4/-3-/1/2/-/" 

Accidentally also implements , (throws away the first argument) and . (append the arguments together)

Perl, 64 53 bytes

Include +1 for -p

perl -pe 's%([*-/])(([\d.]+|(?0))\1(?3))\1%($2)%&&redo;$_=eval' <<< "/4/-3-/1/2/-/" 

Accidentally also implements , (throws away the first argument) and . (append the arguments together)

Source Link
Ton Hospel
  • 15k
  • 1
  • 23
  • 45

Perl, 64 bytes

Include +1 for -p

perl -pe 's%^(([*-/]+)((?1)|\d+)\2((?3))\2)$%( $3 $2 $4 )%m&&redo;$_=eval' <<< "/4/-3-/1/2/-/" 

Accidentally also implements , (throws away the first argument) and . (append the arguments together)