public static StringBuilder appendFunctionArgs ( StringBuilder sb , List < Term < ? > > list ) { Term < ? > prev = null , pprev = null ; for ( Term < ? > elem : list ) { boolean sep = true ; if ( elem instanceof TermOperator && ( ( TermOperator ) elem ) . getValue ( ) == ' ' ) sep = false ; //no spaces before commas if ( ( prev != null && prev instanceof TermOperator && ( ( TermOperator ) prev ) . getValue ( ) == ' ' ) && ( pprev == null || pprev instanceof TermOperator ) ) //nothing or an operator before - sep = false ; //no spaces after unary minus if ( prev != null && sep ) sb . append ( SPACE_DELIM ) ; pprev = prev ; prev = elem ; sb . append ( elem . toString ( ) ) ; } return sb ; }
Appends the formatted list of function arguments to a string builder . The individual arguments are separated by spaces with the exception of commas .