Previous: , Up: formations   [Index]

52.11 Miscellaneous escape sequences

Format Escape Sequence: ~p

Plural. No parameters.

Output nothing if the argument is 1, or ‘s’ for any other value.

(format #t "enter name~p" 1) -| enter name
(format #t "enter name~p" 2) -| enter names

~@p prints ‘y’ for 1 or ‘ies’ otherwise.

(format #t "pupp~@p" 1) -| puppy
(format #t "pupp~@p" 2) -| puppies

~:p re-uses the preceding argument instead of taking a new one, which can be convenient when printing some sort of count.

(format #t "~d cat~:p" 9)   -| 9 cats
(format #t "~d pupp~:@p" 5) -| 5 puppies

~p is designed for English plurals and there’s no attempt to support other languages. ~[ conditionals (below) may be able to help.

Format Escape Sequence: ~~

Tilde character. Parameter: n.

Output a tilde character ~, or n many if a parameter is given. Normally ~ introduces an escape sequence, ~~ is the way to output a literal tilde.

(format "A~~Z")         ⇒ "A~Z"
(format "A~3~Z")        ⇒ "A~~~Z"
Format Escape Sequence: ~!

Force output. No parameters.

At the end of output, call flush-output-port to flush any buffers on the destination. ~! can occur anywhere in the format string, but the force is done at the end of output.

When output is to a string: ~! does nothing.