Page 1 of 1

long line output

Posted: Fri Aug 28, 2015 8:41 am
by anaumov
Hello,

does anybody know why the fomat's output adds a new line symbol after F-string?

Code: Select all

        (setq  L '("AAAAAAAAA#"))
        (nconc L '("BBBBBBBBB#"))
        (nconc L '("CCCCCCCCC#"))
        (nconc L '("DDDDDDDDD#"))
        (nconc L '("EEEEEEEEE#"))
        (nconc L '("FFFFFFFFF#"))
        (nconc L '("GGGGGGGGGG#"))
        (format t "L = ~A~%" L)
That's my ouput:

Code: Select all

L = (AAAAAAAAA# BBBBBBBBB# CCCCCCCCC# DDDDDDDDD# EEEEEEEEE# FFFFFFFFF#
     GGGGGGGGGG#)
I would like to have ONE string.

Thanks,
Alex

Re: long line output

Posted: Fri Aug 28, 2015 1:38 pm
by edgar-rft
How things are printed on the screen is mostly implementation dependent,but here is what I do in such cases.

The following function shows the values of all Common Lisp variables that have anything to do with printing:

Code: Select all

(defun printer-status ()
  (format t ";;           *print-array* = ~a~%" *print-array*)
  (format t ";;            *print-base* = ~a~%" *print-base*)
  (format t ";;            *print-case* = ~a~%" *print-case*)
  (format t ";;          *print-circle* = ~a~%" *print-circle*)
  (format t ";;          *print-escape* = ~a~%" *print-escape*)
  (format t ";;          *print-gensym* = ~a~%" *print-gensym*)
  (format t ";;          *print-length* = ~a~%" *print-length*)
  (format t ";;           *print-level* = ~a~%" *print-level*)
  (format t ";;           *print-lines* = ~a~%" *print-lines*)
  (format t ";;     *print-miser-width* = ~a~%" *print-miser-width*)
  (format t ";; *print-pprint-dispatch* = ~a~%" *print-pprint-dispatch*)
  (format t ";;          *print-pretty* = ~a~%" *print-pretty*)
  (format t ";;           *print-radix* = ~a~%" *print-radix*)
  (format t ";;        *print-readably* = ~a~%" *print-readably*)
  (format t ";;    *print-right-margin* = ~a~%" *print-right-margin*))
Here are the SBCL default values, right after SBCL was started:

Code: Select all

CL-USER> (printer-status)
;;           *print-array* = T
;;            *print-base* = 10
;;            *print-case* = UPCASE
;;          *print-circle* = NIL
;;          *print-escape* = T
;;          *print-gensym* = T
;;          *print-length* = NIL
;;           *print-level* = NIL
;;           *print-lines* = NIL
;;     *print-miser-width* = NIL
;; *print-pprint-dispatch* = #<PPRINT-DISPATCH-TABLE {10001C3633}>
;;          *print-pretty* = T
;;           *print-radix* = NIL
;;        *print-readably* = NIL
;;    *print-right-margin* = NIL
Often it helps to set *PRINT-PRETTY* to NIL, or at least this is the very first thing I would try. Other candidates are *PRINT-RIGHT-MARGIN* and *PRINT-MISER-WIDTH*, if they are not set to NIL (what means they are ignored).

Most Common Lisp implementations have default values for 80 characters per line, what is the line length of most terminal screens.

If that doesn't help I would need to know the name of the Common Lisp implementation you work with.
anaumov wrote:I would like to have ONE string.
To get the value of L as ONE STRING you need to write:

Code: Select all

(format nil "~a" L) => "(AAAAAAAAA# BBBBBBBBB# CCCCCCCCC# DDDDDDDDD# EEEEEEEEE# FFFFFFFFF# GGGGGGGGGG#)"
or maybe something like this:

Code: Select all

(format nil "~{~a~}" L) => "AAAAAAAAA#BBBBBBBBB#CCCCCCCCC#DDDDDDDDD#EEEEEEEEE#FFFFFFFFF#GGGGGGGGGG#"
- edgar

Re: long line output

Posted: Sat Aug 29, 2015 9:45 am
by pjstirling
Can I ask what the goal is here? Your initial example implies you are doing something strange, that may have a better method.

Re: long line output

Posted: Tue Sep 01, 2015 1:33 am
by anaumov
edgar-rft wrote:Often it helps to set *PRINT-PRETTY* to NIL
Thank you very much! This solved my problem.
pjstirling wrote:Can I ask what the goal is here? Your initial example implies you are doing something strange, that may have a better method.
I generate CSV file. The CSV format is pretty easy any I don't want to download/load some library for this. One thing that breaks my CSV is a new line, that SBCL adds after 80'th character by default.