Output

If a statement is an expression that has a value, and the statement ends with a newline without a trailing semicolon, then the value of the statement will be displayed. If the value is a numerical scalar, matrix, character string, or a list of these values, it will be displayed the usual way. If the value is a more ``abstract'' one, such as a function, a hash table, or, a class, the system will try to print some information about it. For example:
>> x = rand(1)
   0.08847010159
>> y = rand(2)
   0.346
   0.53
>> sin
   Builtin function
>> f = x -> sqrt(1+x^2)
   user defined function
To suppress unwanted display of answers, a semicolon should be appended at the end of the statement.

The built-in function print will display the value of its operand, even if the line that contains print ends with a semicolon. The print function takes one argument, and display its value, but does not return anything. For example

>> print(cos);
   Builtin function

How values are displayed by print function is defined by the system, and cannot be modified. To display data in customized ways, the formatted output function printf and sprintf can be used.



oz 2009-12-22