Script Name: Prefix Expression Evaluator
Script Description: Evaluates an expression (prefix notation) Example: PEvaluate('+ * 4 3 7') returns '19'. This is for scripters, not server owners. If you wish to use this script in your script, feel free to, but please note my name.
Original Author: DorkeyDear (Curt)
Core Version: 2.6.3
Required Files:filename (minimal version) linkconvert.pas (5)
http://curt.soldatrs.com/boosters/convert.pasmath.pas (20)
http://curt.soldatrs.com/boosters/math.passtrops.pas (3)
http://curt.soldatrs.com/boosters/strops.paspexpreval.pas (1.3)
http://curt.soldatrs.com/boosters/pexpreval.pasWhat is Prefix Notation?Prefix notation is a notation of writing out expressions
Just like we do "4 + 3" in infix notation, we would do "+ 4 3" in prefix notation
For something more complex, we have "(x + 1) / (x - 1)" in infix notation, we would do "/ + x 1 - x 1" in prefix notation
Reasons of...preferenceArgument length specifiable
Faster than my Expression Evaluator
Easy to learn
No parenthesis
No order of precedence
Dynamic argument count
avoidanceNot used to the style (majority of people do not know the syntax)
Confusing to look at
Notes:Case-sensitive
Ignores double spaces, single space required separator
Prompting a boolean, anything non-0 is true
Returning a boolean, 1=true, 0=false
Dynamic argument count functions will require the required arguments first, then the count of dynamic arguments; ex "sum a b ..." length will be -3, and we want to add some numbers, here is how it would work "sum 10 9 2 8 7" and 10, 9, 8, and 7 will be operated on; note that if you want 0 dynamic arguments, you still will require to put the zero, "sum 10 9 0"
Operators and Functions:pi:
float; value of pi
e:
float; value of e
phi
float; value of Phi
abs
float:
float; absolute value
sign
float:
integer; sign (-1 for negatives, 0 for 0, 1 for positives)
int
float:
integer; integer part of value
float
float:
float; float part of value
roundto
float integer:
float; rounds to nearest specified decimal place
round
float:
integer; rounds to the nearest integer
floor
float:
integer; floors the number
ceil
float:
integer; ceilings the number
sqrt
float:
float; square-root
sin
float:
float; sine
cos
float:
float; cosine
tan
float:
float; tangent
sec
float:
float; secant
csc
float:
float; cosecant
cot
float:
float; cotangent
arcsin
float:
float; arc-sine
arccos
float:
float; arc-cosine
arctan
float:
float; arc-tangent
arcsec
float:
float; arc-secant
arccsc
float:
float; arc-cosecant
arccot
float:
float; arc-cotangent
ln
float:
float; natural logarithm (slow and inaccurate)
not
boolean:
boolean; not
bool
float:
boolean; returns boolean value
fac
integer:
integer; factorial
ncr
integer integer:
integer; combination
npr
integer p
integer:
integer; permutation
pow
float integer:
float; exponents
*
float float:
float; multiplication
/
float float:
float; division
%
float float:
float; modulus
+
float float:
float; addition
-
float float:
float; subtraction
<<
integer integer:
integer; bit shift left
>>
integer integer:
integer; bit shift right
<
float float:
boolean; less than
<=
float float:
boolean; less than or equal to
>
float float:
boolean; greater than
>=
float float:
boolean; greater than or equal to
==
float float:
boolean; equal to
!=
float float:
boolean; not equal to
and
boolean boolean:
boolean; logical and
xor
boolean boolean:
boolean; logical xor
or
boolean boolean:
boolean; logical or
sum
integer float..:
float; sum
mtp
integer float..:
float; multiplies
min
integer float..:
float; smallest value
max
integer float..:
float; largest value
con
string string:
string; concatenate
conn
integer string..:
string; concatenate
Please report any bugs or suggestions