0
(call-with-output-file "b.txt"
(lambda (output-port)
(display "hello, world" output-port)))

How to open the b.txt in append mode. So that, my results will be appended in the text file. I have found some answer in the following. But that's not what i expect.

Append in scheme

I want to work with "call-with-output-file". Since i find this properly working. With this call-with-output-file, how can i append?

Community
  • 1
  • 1
vishnu
  • 891
  • 2
  • 11
  • 20

1 Answers1

1

The link you mention presents a correct solution. In guile, the suggestion by Óscar López will not work, as its call-with-output-file has no #:exists keyword. However, this should work:

(let ((output-port (open-file "my.txt" "a")))
  (display "hello, world" output-port)
  (newline output-port)
  (close output-port))

You can find the code for call-with-output-file in ice-9/boot-9. It would be easy to extend it to support appending.

Michael Vehrs
  • 3,293
  • 11
  • 10