Reputation: 55
I'm having problems getting the display-lines-to-file working, here is what I have tried:
(define (list-to-file lst file) (display-lines-to-file lst file
#:exists 'replace
#:separator newline #"\n"))
(list-to-file myList "myfile.txt")
myList is a list of data that was read from another file, after processing that data I need to write the contents of the list (including newline characters) to myfile.txt
Upvotes: 2
Views: 532
Reputation: 16250
Racket keyword arguments have a #:keyword
followed by a single value. The problem seems to be:
#:separator newline #"\n"
Instead you want:
#:separator #"\n"
I'd suggest a few other changes:
#:separator
is already #"\n"
, omit that.#:mode 'text
so that \n
is automatically translated to \r\n
on Windows.Combining all that:
(define (list->file lst file)
(display-lines-to-file lst
file
#:exists 'replace
#:mode 'text))
Upvotes: 1