* Pretty Printing values from a hashmap
@ 2022-07-21 9:13 Munyoki Kilyungi
2022-07-21 10:14 ` Munyoki Kilyungi
2022-07-21 11:28 ` adriano
0 siblings, 2 replies; 3+ messages in thread
From: Munyoki Kilyungi @ 2022-07-21 9:13 UTC (permalink / raw)
To: guile-user
[-- Attachment #1: Type: text/plain, Size: 613 bytes --]
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:
--8<---------------cut here---------------start------------->8---
#<hash-table 7f56164e9340 2/31>
--8<---------------cut here---------------end--------------->8---
--
(Life is like a pencil that will surely run out,
but will leave the beautiful writing of life.)
(D4F09EB110177E03C28E2FE1F5BBAE1E0392253F
(hkp://keys.gnupg.net))
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 865 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Pretty Printing values from a hashmap
2022-07-21 9:13 Pretty Printing values from a hashmap Munyoki Kilyungi
@ 2022-07-21 10:14 ` Munyoki Kilyungi
2022-07-21 11:28 ` adriano
1 sibling, 0 replies; 3+ messages in thread
From: Munyoki Kilyungi @ 2022-07-21 10:14 UTC (permalink / raw)
To: guile-user
[-- Attachment #1: Type: text/plain, Size: 1284 bytes --]
Munyoki Kilyungi <me@bonfacemunyoki.com>
anaandika:
> 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)
(newline)
(display (car x))
(display ":\n")
(map (lambda (x)
(format #t "~a:\n" (car x))
(pretty-print (hash-map->list cons (cdr x)))
(newline))
(hash-map->list cons (cdr x)))
(newline))
h))
(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.)
(D4F09EB110177E03C28E2FE1F5BBAE1E0392253F
(hkp://keys.gnupg.net))
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 865 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Pretty Printing values from a hashmap
2022-07-21 9:13 Pretty Printing values from a hashmap Munyoki Kilyungi
2022-07-21 10:14 ` Munyoki Kilyungi
@ 2022-07-21 11:28 ` adriano
1 sibling, 0 replies; 3+ messages in thread
From: adriano @ 2022-07-21 11:28 UTC (permalink / raw)
To: Munyoki Kilyungi, guile-user
Il giorno gio, 21/07/2022 alle 12.13 +0300, Munyoki Kilyungi ha
scritto:
>
> 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:
>
> --8<---------------cut here---------------start------------->8---
> #<hash-table 7f56164e9340 2/31>
> --8<---------------cut here---------------end--------------->8---
>
The Guile pretty printer doesn't support hashmaps
I see 2 options
1) you convert your hashmap into an alist and print that
2) you extend the pretty printer to support hashmaps too and send a
patch
as for the 2nd option, I was suggested to do so myself, not so long ago
but I couldn't bring myself to do that
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-21 11:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-21 9:13 Pretty Printing values from a hashmap Munyoki Kilyungi
2022-07-21 10:14 ` Munyoki Kilyungi
2022-07-21 11:28 ` adriano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).