I have a basic Racket program:
hello.rkt:
(write "Hello, World!")
When I run it with racket -f hello.rkt
, I get the following output:
"Hello, World!"
Is there a special compiler flag, or special version of "write/print" that removes the quotes from string output, so that it shows:
Hello, World!
The write
function is the dual to read
: it outputs (or at least attempts to output) datums that could be read
back in to produce the original value. In my experiences, it is not often terribly useful even for that purpose, but it can be helpful when you’re debugging.
For actual output, the function you want is display
. This outputs the actual data itself to the output port, not a formatted representation of it.
For completeness, Racket has an additional printing function, called print
. Unlike display
and write
, print
is explicitly designed to be used for debugging. Its output can be customized by a variety of different parameters, so the output format is uses it not necessarily predictable, and it shouldn’t be used for anything other than debugging. For that purpose, though, it’s quite useful.
Use display
instead of write
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With