| Calling Sequence | print(e1,e2,...)
| |||||||||
| Parameters |
| |||||||||
| Return Type | NULL | |||||||||
| Synopsis | This function attempts to print out the contents of each e_{i} in a pretty/readable manner. Any user-defined data structures/classes named, for example ClassName, can make use of the print command by creating a procedure named ClassName_print. This routine should detail the manner in which the data structure is to be sent to the standard output. Any invocation of the print statement on an object of type ClassName will automatically invoke this routine. All built-in Darwin data structures have such a routine. Floating point numbers are printed with 5 significant digits. The global variable NumberFormat can be assigned a format, as in the printf function, and all numbers will be printed accordingly. | |||||||||
To print procedures there are two options. Print on a procedure produces a short description based on the parameters, description field (if any) and return type. To print the body or the procedure (code) the function disassemble should be used in conjunction with print. This produces a nice albeit not perfect formatting. | ||||||||||
| Examples | > x:= [[1,2],[3,4]]; x := [[1, 2], [3, 4]] > print(x); 1 2 3 4 > f := proc(x:positive) description 'test example';
for i to 20 do x+i od; i+sin(x) end:
> print(f); f: Usage: f( x:positive ) test example > print(disassemble(op(PartialFraction))); proc( r:numeric, eps:numeric )
local t, t2;
if nargs = 1 then procname(r, 1e-05)
elif r < 0 then t := procname(-1*r,eps); [-1*t[1], t[2]]
elif 1 < r*eps then [round(r), 1]
elif r < eps then [0, 1]
elif type(r,integer) then [r, 1]
else
t2 := floor(r);
if r-1*t2 < eps then [t2, 1]
else t := procname((r-1*t2)^(-1),r^2*eps); [t2*t[1]+t[2], t[1]] fi
fi
end:
| |||||||||
| See also | dprint, lprint, printf, prints | |||||||||