Common Lisp Library for Pretty Printing? e.g. pretty print a nested hash table

前端 未结 3 1476
终归单人心
终归单人心 2021-01-18 07:27

I am new to common lisp. Is there a CL library to pretty print collections, in my case, nested hash tables?

3条回答
  •  抹茶落季
    2021-01-18 08:02

    If you consider writing it yourself here is a starting point using print-object. It is not implementation independend, but this works at least in LispWorks and SBCL.

    (defmethod print-object ((object hash-table) stream)
      (format stream "#HASH{~{~{(~a : ~a)~}~^ ~}}"
              (loop for key being the hash-keys of object
                    using (hash-value value)
                    collect (list key value))))
    

提交回复
热议问题