Re: How to avoid new line from stream

Max Zettlmeißl via clisp-list <[email protected]> Fri, 3 Aug 2018 05:40:40 +0200
Newsgroups gmane.lisp.clisp.general
Message-ID <CACjvM=d4LvWvHtCZ_YA9F4X8kBSZ4vQ0cOtHu8BsopJPa6s4dA@mail.gmail.com>
On Fri, Aug 3, 2018 at 4:25 AM, Jean Louis <[email protected]> wrote:
> I am trying to solve the problem here that if
> there is no ending newline, my function is still
> printing it.
>
>     (setf result (format nil "~{~A~%~}" (loop for line = (read-line in nil)
>                                          while line
>                                          collect line)))
>
> while I would need "something" as result. Somebody knows solution?
>

What is happening here is no surprise.
Your format control string contains directions to append a line ending
after every element in your list. ("~%")
If you change it into "~{~A~}" you get your desired behaviour.

There are many other things about your function which are rather
unclean: a starting point would be to use with-open-stream and
with-input-from-stream.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
clisp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-list