.TH POLISH 3carl CARL
.SH NAME
polish \- convert mathematical expression to reverse polish notation
.SH SYNOPSIS
.B #include <carl/frm.h>
.sp
.B char *polish(expression, unops, binops, postops)
.br
.B char *expression, *unops, *binops, *postops;
.sp
.B cc [ -flags ] files -lfrm -lm [ libraries ]
.SH DESCRIPTION
.B polish 
processes 4 strings as arguments: 
.I expression
is a string containing 
an expression to be transformed into reverse polish notation, and 
.I unops, 
.I binops, 
and 
.I postops 
are strings describing unary, binary, and post operators 
to be recognized in the expression. Anything in the expression not 
recognized as an operator is taken to be an operand.  
A pointer to a (static) string containing the polish form of 
.I expression 
is returned.  
.PP
The operator strings are ordered lists of sets, with operators in the first
set done before operators in the second set, which are done before operators
in the third, etc. Sets are notated as a list of comma-separated items
enclosed in braces (``{}''). For example, the string ``{*,/}{+,-}'' as 
.I binops 
would specify that ``*'' and ``/'' are to be done before ``+'' and ``-''.  
.PP
Unary operators are always done before binary, and binary before post 
operators. 
.PP
Operators may be more than single characters; in particular, functions
and post operators are may be treated as multicharacter 
.I unops 
and 
.I postops.
.PP
.I Polish 
returns a string in reverse polish notation consisting of 
comma-separated fields, each containing a symbolic item (either an operator 
or an operand) followed by a dollar sign, followed by a digit. The digit 
is the number of operands of the item, which is zero for operands, 1 for 
unary and post operators, and 2 for binary operators. (Someday function 
calls, which are treated as UNOPS, may allow more than 1 argument as well).
.PP
Example:
.br
polish("-3+(-p4-ln(v3)*p5)Hz",
.br
   "{sin,cos,ln}{-}","{*,/}{+,-}","{dB,Hz}");
.br
 will return the following string:
.br
"3$0,-$1,p4$0,-$1,v3$0,ln$1,p5$0,*$2,-$2,+$2,Hz$1,"
.ne 4
.SH AUTHOR
F. R. Moore
.SH SEE ALSO
expr(3carl)
