I wrote this code to write of a file:
(defun writefile (text filename)
(with-open-file (stream filename :direction :output :if-exists :supersede
:if-does-not-exist :create)
(format stream text)))
but if i execute, for example:
(writefile '(a b c) "foo.txt")
returns:
Error: In a call to FORMAT: (A B C) is not of type (OR STRING FUNCTION).
Why it shows me that error?
Your format call is wrong:
the second argument should be either a
string or a
function (cf. the error message!)
You need to replace it with (format stream "~S" text) or just use prin1 or 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