next up previous contents
Next: Upper and lower case Up: String manipulation Previous: String manipulation

String replacement

Character replacement is possible using standard transformation rules. As an example, output strings can be compacted using AssignReplace->{ ->} and this is the default for FortranAssign. The advantage is a reduction in the number of lines of code needed to represent an expression, which makes line-breaking more efficient. This technique can be used to substitute for other strings, such as to replace generic function types.

In[4]:= FortranAssign[Sin[x],AssignReplace->{"sin"->"dsin"}]

Out[4]//OutputForm=
        dsin(x)
The replacement is literal in the sense that exact character sequences are substituted and should be used with caution. In this example an ANSI FORTRAN function is not obtained.

In[5]:= FortranAssign[ArcSin[x],AssignReplace->{"sin"->"dsin"}]

Out[5]//OutputForm=
        adsin(x)



Jorge Romao
5/14/1998