[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pretty Printing values from a hashmap

From: Munyoki Kilyungi
Subject: Re: Pretty Printing values from a hashmap
Date: Thu, 21 Jul 2022 13:14:09 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux)

Munyoki Kilyungi <>

> Hi!  Say I have a hashmap that has nested hashmaps
> that I want to inspect.  Is there a way to just
> printing it out on my display in a
> straight-forward way without having to loop inside
> the key-value pairs?  Printing a hashmap outputs
> something like this:
> #<hash-table 7f56164e9340 2/31>

FWIW, I've come up with something that looks like:

--8<---------------cut here---------------start------------->8---
(use-modules (ice-9 pretty-print))

(define (print-hash-map h)
  (map (lambda (x)
       (display (car x))
       (display ":\n")
       (map (lambda (x)
              (format #t "~a:\n" (car x))
              (pretty-print (hash-map->list cons (cdr x)))
            (hash-map->list cons (cdr x)))

(print-hash-map (hash-map->list cons (dataset-csv-reader "rand.csv")))
--8<---------------cut here---------------end--------------->8---

I think the above is clanky as I already know the
structure of my hashmap before-hand.
(Life is like a pencil that will surely run out,
    but will leave the beautiful writing of life.)

Attachment: signature.asc
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]