Formatted Output to Character Streams in LISP Last Updated : 26 Jul, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report Lisp is a programming language that has an overall style that is organized around expressions and functions. Every Lisp procedure is a function, and when called, it returns a data object as its value. It is also commonly referred to as “functions” even though they may have side effects. Formatted Output to Character Streams:The function format is used to produce nice formatted text, good-looking messages, and so on. the format can generate a string or output to a stream. Syntax: format destination control-string &rest arguments where, destination -> standard outputcontrol-string -> hold the characters that to output and printing directive. A format directive consists of a tilde (~), optional prefix parameters separated by commas, an optional colon (:) and at-sign (@) modifiers, and a single character indicating the type of directive. The prefix parameters are generally integers, notated as optionally signed decimal numbers. The following commonly used directives used for output streams are: S.No.Directives Description1~BFor binary arguments.2~DFor decimal arguments.3 ~SIs followed by S-expressions.4~AIs followed by ASCII arguments.5 ~OFor octal arguments.6~$Dollar and floating point arguments.7~EExponential floating-point arguments.8~FFor Fixed-format floating-point arguments.9~CFor character arguments.10 ~XFor hexadecimal arguments.11~*The next argument is ignored.12~?Indirection. The next argument must be a string, and the one after it a list.13~%A new line is printed.14 ~^Up and out. This is an escape construct.15~>Terminates a ~<. It is an error elsewhere.16~}This terminates a ~{. It is an error elsewhere.17~;This separates clauses in ~[ and ~< constructions. It is an error elsewhere.18~(str~)Case conversion.19~[str0~;str1~;...~;strn~]Conditional expression. This is a set of control strings, called clauses.20~W Write. In an argument, a Lisp object is printed obeying every printer control variable.Example 1: Lisp ; Formatted Output to Character Streams in LISP (format t "Hello, World!") (format nil "foo") (setq x 10) (format nil "The answer is ~D." x) (format nil "The answer is ~3D." x) (format nil "The answer is ~3,'0D." x) (format nil "The answer is ~:D." (expt 47 x)) (setq y "cat") (format nil "Look at the ~A!" y) (setq n 3) (format nil "~D item~:P found." n) (format nil "~R dog~:[s are~; is~] here." n (= n 1)) (format nil "~R dog~:*~[s are~; is~:;s are~] here." n) (format nil "Here ~[are~;is~:;are~] ~:*~R pupp~:@P." n) Output: Example 2: Lisp ;Formatted Output to Character Streams in LISP (defun perimeterofsquare() (terpri) (princ "Enter side length: ") (setq length (read)) (setq peri (* 4 length)) (format t "Length: = ~F~% Perimeter = ~F" length peri) ) (perimeterofsquare) Output: Comment More infoAdvertise with us Next Article 10 Ways to Create a Stream in Java R rupeshgulia599 Follow Improve Article Tags : LISP Similar Reads Input From Character Streams in LISP This article is about input from character streams in LISP. Input in LISP can be taken in different ways like input from the user, input from character streams, etc. In LISP input from character streams can be taken from different functions accordingly. Input from character streams can be a string, 3 min read Characters in LISP In Lisp data objects of type 'character' are referred to as characters. For representation purposes, we usually denote character objects by preceding a #\ symbol before the character. Any character can be represented by using the #\ symbol before the name of the character. For Example #\a represents 2 min read Output Functions in LISP Output functions need an optional argument known as output stream which by default is "output-stream" and can be assigned to another stream where the output has to be sent. Write:write object  key : stream Example 1: Lisp ; LISP program for Write (write "Hello World") (write "To") (write "The") (wr 3 min read 10 Ways to Create a Stream in Java The Stream API, introduced in Java 8, it is used to process collections of objects. Stream is a sequence of objects, that supports many different methods which can be pipe lined to produce the desired result. The features of Java stream are â A stream is not a data structure alternatively it takes i 9 min read 10 Ways to Create a Stream in Java The Stream API, introduced in Java 8, it is used to process collections of objects. Stream is a sequence of objects, that supports many different methods which can be pipe lined to produce the desired result. The features of Java stream are â A stream is not a data structure alternatively it takes i 9 min read How to print output in Ruby? An essential aspect of programming involves the ability to print output, This allows developers to not only communicate information with users but also debug code and present results. Within Ruby, a potent and adaptable language for programming, numerous methods exist for printing output directly in 4 min read Like