Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between write, print, pprint, princ, and prin1?

Tags:

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?

like image 541
Electric Coffee Avatar asked Nov 03 '13 18:11

Electric Coffee


People also ask

What is the difference between pprint and print?

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.

What does Princ mean in LISP?

(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.

What is Princ in autolisp?

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.

What is Terpri in LISP?

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.


Video Answer


1 Answers

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.
like image 101
Rainer Joswig Avatar answered Oct 18 '22 16:10

Rainer Joswig