print_preprocess
obtain pretty-printed form of expressions
Calling Sequence
Parameters
Description
Examples
print_preprocess(e)
e
-
any expressions
The function print_preprocess returns the pretty-printed form of an expression, as print would display it.
In particular, procedures of the form `print/foo` are applied to functions foo(a, b, ...) and ModulePrint procedures are applied to modules. This is particularly useful when you write a `print/foo` or ModulePrint procedure and want to display a subobject.
The module m below displays in the same way as its member m:-a, but with square (list) brackets around it.
m := module() export a; local ModulePrint := proc() return [print_preprocess(a)]; end proc; end module:
m:-a≔5:eval⁡m
5
m:-a≔LinearAlgebra:-RandomMatrix⁡20:eval⁡m
The function foo(...) displays in reverse.
`print/foo` := proc() local oof, i; return oof(seq(print_preprocess([_passed][i]), i = _npassed .. 1, -1)); end proc:
foo⁡1,2
oof⁡2,1
m:-a≔foo⁡1,2:eval⁡m
See Also
ModuleDeconstruct
ModulePrint
print
Download Help Document
What kind of issue would you like to report? (Optional)