up previous next
1.1.6 Tutorial: printing
The way CoCoA-5 can show us the results of its computation is by (so-called) printing them on the screen.

At top level, if you type in an expression for a computation, CoCoA-5 will evaluate the expression, and then automatically print out the answer. This is convenient for interactive use.

Inside a function definition you must use explicitly a printing command: the two fundamental printing commands are println and print . The only difference between them is that the first command also prints out a newline at the end; this is usually what is desired.

The procedure indent is useful for printing out long lists of values: it prints a newline after each list entry (whereas print and println will print all entries on the same line).

To help comprehend the true size of large integers or rationals there is the function FloatStr which prints out the value using an easy-to-understand floating-point format.

/**/ 1+2; // an expression at top level
/**/ println 1; println 2;
/**/ print 1; print 2;
/**/ println [11,22];
[11, 22]
/**/ indent([11,22]);