Created
May 1, 2014 20:36
-
-
Save kevinwright/547e2012a152deb64de1 to your computer and use it in GitHub Desktop.
minified evaluator
This file contains 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
#!/bin/bash | |
set -f | |
SUBBED=($(sed -e "s,multiply,*,g" -e "s,divide,/,g" -e "s,add,+,g" -e "s,subtract,-,g" -e "s,apply,,g" -e "s, *,,g" $1)) | |
EXPR="" | |
for (( idx=${#SUBBED[@]}-1 ; idx>=0 ; idx-- )) ; do EXPR="($EXPR ${SUBBED[idx]})"; done | |
echo $(($EXPR)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment