Perhaps `display-to-file`? #lang racket (require racket/file) (define (write-to-file path string-list) (for ([line string-list]) (display-to-file line path #:exists 'append)))
> On Feb 17, 2018, at 9:56 AM, Zelphir Kaltstahl <zelphirkaltst...@gmail.com> > wrote: > > > I am writing to a file using the following procedure: > > ~~~ > ;; Writes a list of strings as lines to a file. > (: write-to-file (-> Path-String (Listof String) Void)) > (define (write-to-file path string-list) > (call-with-output-file path #|#:mode 'text|# #:exists 'append > (λ ([output-port : Output-Port]) > (printf "Output port: ~s~n" output-port) > (for ([line string-list]) > #;(write-bytes (string->bytes/utf-8 (format "~s~n" line)) output-port) > #;(write-string (format "~s~n" line) output-port) > (display line output-port) > (parameterize ([print-as-expression #t]) > (print line output-port 0)) > #;(printf "~s~n" line output-port) > #;(write line output-port) > #;(write newline output-port))))) > ~~~ > > Writing to a file using display or displayln works as I wanted to write, but > all other ways I tried add double quotes for strings which I am writing, so > that the double quotes appear in the output file. I also tried some stuff > like string->bytes/utf-8 and write-bytes but that did not change that double > quotes get into the file. > > The docs here > <https://docs.racket-lang.org/reference/Writing.html#%28def._%28%28quote._~23~25kernel%29._print%29%29> > seem to say that I can make print output to a an output port any way I want > and if it is not too complicated, I might want to use print instead of > display to write to a file, for naming reasons. print sounds more like > something that is actually writing to a file than display, at least to me. > > How would I make print behave like display? -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.