print_preprocess - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


print_preprocess

obtain ready-to-pretty-print form of expressions

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

print_preprocess(e)

Parameters

e

-

any expressions

Description

• 

When a Maple expression is about to be printed, either via a call to the print function, or as output from a user-entered command, the expression undergoes print preprocessing. This modifies the expression in ways that make it easier for the user interface to render it in a suitable form, or to make it more human-readable.

  

Print preprocessing performs the following actions:

• 

Names of tables, procedures, and modules are replaced by their values.

• 

Procedures of the form `print/foo` are applied to unevaluated functions of the form foo(a, b, ...).

• 

ModulePrint procedures/methods are applied to modules and objects.

• 

Arrays, Matrices, Vectors, and tables are converted to a more compact form if they would be unwieldy to display.

• 

The print_preprocess function can be used to apply print preprocessing to an expression, returning the preprocessed expression instead of printing it. (If the returned value were printed, it would produce the same output as printing the original expression.)

• 

The print_preprocess function is most often used within a `print/foo` or ModulePrint procedure to recursively apply print preprocessing to a subexpression.

• 

The lprint function does not perform full print preprocessing, since its purpose is to produce output that is syntactically correct Maple input that recreates the original expression. It does do some preprocessing however:

• 

Arrays, Matrices, and Vectors are processed.

• 

ModuleDeconstruct procedures/methods are applied to modules and objects (the purpose of ModuleDeconstruct is to generate a call to a constructor expression that would recreate the module or object if executed).

Examples

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:-a5:evalm

5

(1)

m:-aLinearAlgebra:-RandomMatrix20:evalm

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:

foo1,2

oof2,1

(2)

m:-afoo1,2:evalm

oof2,1

(3)

Use lprint to see the actual result of print_preprocess. Here, the outer list was produced by the ModulePrint procedure, and the oof(...) structure by `print/foo`, which in turn was called as a result of the call to print_preprocess within ModulePrint:

lprintprint_preprocessevalm

[oof(2,1)]

Since lprint itself does not perform print preprocessing, it can also be used to see what the actual expression looks like:

lprintevalm

module () local ModulePrint; export a; ModulePrint := proc () return [print_preprocess(a)] end proc; a := foo(1,2); end module

See Also

ModuleDeconstruct

ModulePrint

print