long line output

Discussion of Common Lisp
Post Reply
anaumov
Posts: 10
Joined: Thu Sep 15, 2011 4:13 am
Location: Germany
Contact:

long line output

Post by anaumov » Fri Aug 28, 2015 8:41 am

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

edgar-rft
Posts: 226
Joined: Fri Aug 06, 2010 6:34 am
Location: Germany

Re: long line output

Post by edgar-rft » Fri Aug 28, 2015 1:38 pm

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

pjstirling
Posts: 166
Joined: Sun Nov 28, 2010 4:21 pm

Re: long line output

Post by pjstirling » Sat Aug 29, 2015 9:45 am

Can I ask what the goal is here? Your initial example implies you are doing something strange, that may have a better method.

anaumov
Posts: 10
Joined: Thu Sep 15, 2011 4:13 am
Location: Germany
Contact:

Re: long line output

Post by anaumov » Tue Sep 01, 2015 1:33 am

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.

Post Reply