User:Wladek92/lisp


 * translation of .po files format Lisp
 * source: https://en.wikipedia.org/wiki/Format_(Common_Lisp)
 * ide  : https://www.jdoodle.com/execute-clisp-online/
 * ide  : https://www.jdoodle.com/execute-clisp-online/


 * https://sourceforge.net/p/clisp/clisp/ci/default/tree/src/po/clisp.pot
 * https://sourceforge.net/p/clisp/clisp/ci/default/tree/src/po/clisplow_fr.po

(print (+ 2 3) )
 * meta character ~ (tilde)
 * ~[prefixParameters][modifiers]directiveType

(format t "~C~C" #\return #\linefeed) (format t "Hello world.~%")
 * passage a la ligne
 * the FORMAT control ~% prints a newline (!).

(format T "calcul simple: 10 + 20 = ~d~%" 30) (format T "binaire simple pour ~d: ~b~%" 13 13) (format T "padding gauche sur 8 char: ~8,'0b~%" 5)
 * Prints "1 + 2 = 3" to the standard output and returns ``NIL''.
 * format binaire
 * padding a gauche

(let ((number-of-digits 6)) (declare (type (integer 0 *) number-of-digits))  (format T "padd left variable 6 char: ~v,'0b~%" number-of-digits 5)) (defun print-as-hexadecimal (number-to-format number-of-digits) "Prints the NUMBER-TO-FORMAT in the hexadecimal system (radix 16),   left-padded with zeros to at least NUMBER-OF-DIGITS."  (declare (type number        number-to-format))  (declare (type (integer 0 *) number-of-digits))  (format T "hexa format using local defun print-as-hexadecimal: ~v,'0x~%" number-of-digits number-to-format))
 * V pour longueur variable passée dans parameterlist

(print-as-hexadecimal 12 2)

(format T "~#[none selected~;one selected: ~a~;two selected: ~a and ~a~:;more selected: ~@{~a~^, ~}~]~%")
 * Directive conditionnelle
 * Prints "none selected".

(format T "~#[none selected~;one selected: ~a~;two selected: ~a and ~a~:;more selected: ~@{~a~^, ~}~]~%" 'bunny)
 * Prints "one selected: BUNNY".

(format T "~#[none selected~;one selected: ~a~;two selected: ~a and ~a~:;more selected: ~@{~a~^, ~}~]~%" 'bunny 'pigeon)
 * Prints "two selected: BUNNY and PIGEON".

(format T "~#[none selected~;one selected: ~a~;two selected: ~a and ~a~:;more selected: ~@{~a~^, ~}~]~%" 'bunny 'pigeon 'mouse)
 * Prints "more selected: BUNNY, PIGEON, MOUSE".

(format T "@ modifier for always sign: ~@b~%" 5)
 * @ modifier: always a number's sign
 * @ modifier: always a number's sign

(format T "string format: ~S~%" "Bonjour")

(format NIL "1 + 2 = ~d" 3)
 * Creates and returns a new string containing "1 + 2 = 3".

(with-output-to-string (output) (format output "1 + 2 = ~d" 3))
 * Creates and returns a new string containing "1 + 2 = 3".

(let ((output-string (make-array 0 :element-type 'character :adjustable T                      :fill-pointer 0)))  (declare (type string output-string))  (format output-string "2 + 2 = ~d" 4)  (the string output-string))
 * Appends to the dynamic string the string "1 + 2 = 3".