Plain Lisp library for content printing? for example, it is enough to print a nested hash table

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

+4
source share
2 answers

If you thought about writing it yourself, this is the starting point using print-object . This is not an implementation independently, but it 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))))
+3
source

Firstly, CL is not a collection type.

Secondly, some (most?) CL implementations will print hash tables with content if you set *print-array*to t.

-, CL , , , , hash-table->alist.

+2

Source: https://habr.com/ru/post/1535276/


All Articles