I'm getting into some Lisp, and I've come across various different functions that to me appear to be doing the same thing... Namely printing to console... So what exactly is the difference between all those different functions?
The purpose is very simple, it is for printing anything in python. pprint() function also has similar functionality. But the only difference is in the way it prints complex data structures. The normal print() function prints the entire content in a single line.
(princ [expression [file-descriptor]])Print, taking into account control characters. This function prints to a file or to the screen. When a file-descriptor is provided, LISP prints to a file; when the file-descriptor is missing, LISP prints to the Prompt History window.
Prints an expression to the command line, or writes an expression to an open file. (princ [expr [file-desc]]) This function is the same as prin1 , except control characters in expr are printed without expansion.
Frill-free printing in LISP is achieved with print, prin1, princ and terpri. The simplest uses of print, prin1, and princ involve a single argument. Terpri, which produces a newline, can be called with no arguments. All these are functions.
This is answered here: http://www.lispworks.com/documentation/HyperSpec/Body/f_wr_pr.htm
write
is the general entry point to the Lisp printer. prin1
produces output suitable for input to read
.princ
is just like prin1
except that the output has no escape characters. princ
is intended to look good to people, while output from prin1
is intended to be acceptable for the function read
.print
is just like prin1
except that the printed representation of object is preceded by a newline and followed by a space.pprint
produces pretty output.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With