(princ (concatenate 'string "hello, " "world"))
;; => hello, world
;;
;; "hello, world"concatenatecan be used with different types, we need to specify the output type with the'stringsymbol.
(princ (format nil "1 + 1 = ~a" (+ 1 1)))
;; => 1 + 1 = 2
;;
;; "1 + 1 = 2"formatis a function for creating formatted stringsniltellsformatto evaluate to the string it creates~ais a format directive. It prints the next argument toformat_a_esthetically.- All
formatdirectives start with~
(format t "~a" (/ 4.0 5.0))
;; => 0.8
;;
;; NIL- floating point numbers have a
.in them - when the second argument to
formatistit prints the string to standard out - in this case
formatevaluates tonil
(+ 1/2 1/4)
;; => 3/4- Lisp has rational numbers as a separate type - they are written with a
/between the numerator and the denomenator.
(and t nil)
;; => NIL
(and "ada" 5 "alonzo")
;; => "alonzo"
(and)
;; => T
(or t nil)
;; => T
(or nil "lucy" nil)
;; => "barry"
(or)
;; => NIL
(not nil)
;; => T
(not "amy")
;; => NIL- There is no true or false - only
tandnil tandnilare special symbols; they always evaluate to themselves- anything that's not
nilis treated as true! andandorcan take multiple valuesandreturns the firstnilor the last non-nilargumentorreturns the first non-nilargumentnotwill returnnilfor all non-nilvalues, andtfornil
Common Lisp Hyperspec: FORMAT Common Lisp Hyperspec: Formatted output Practical Common Lisp: A Few Format Recipes