Hello, I'm new to racket. I want to learn format string like other languages. Chatgpt tells me these methods have. but it doesn't have.do you know how way to learn string format methods?
Basic Format Types:
~a
: Display the argument as-is.~s
: Display the argument as a string and escape special characters.~v
: Format the argument according to its natural "vector style."
Numeric Format Types:
~f
: Fixed-point notation for floating-point numbers.~e
,~E
: Exponential notation for floating-point numbers.~g
,~G
: General notation, which uses either fixed-point or exponential notation, depending on the number's magnitude.
Width and Precision Control:
~w
: Specify the minimum width for the argument.~.n
: Specify the number of decimal places for floating-point numbers (e.g.,~.2f
for two decimal places).~<n>
: Specify the total width for the argument (e.g.,~<5>
for a width of 5 characters).
Alignment and Padding:
~c
: Center-align the argument within the field.~r
: Right-align the argument within the field.~l
: Left-align the argument within the field.~a<fmt>
: Apply a specific format to an argument within the field (e.g.,~a<~r>
to right-align the argument).
String and Character Formatting:
~c
: Display a character.~s
: Display a string.~a
: Display the argument as-is.
Custom Format Specifiers:
~<custom>
: Define custom format specifiers and provide a corresponding function to format the argument.
Conditional Formatting:
~?
: Conditionally format the argument based on a predicate.
Escape Sequences:
~~
: Display a tilde (~
) character.~%
: Insert a newline.~,
: Insert a space.~t
: Tab character.~|
: Form feed character.
Other Directives:
~n...~a
: Format a list of arguments using the format string specified in~n
.~i
: Include the identifier of the current module.~v
: Include the values of module variables.~:c
: Apply a character escape.