diff options
author | elioat <elioat@tilde.institute> | 2022-12-06 07:20:41 -0500 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2022-12-06 07:20:41 -0500 |
commit | 120f12b197d3a2b9ae0fda4583e5d54b3001ecd7 (patch) | |
tree | 8fe400617a2ded020ccc6bd55b34019c14d988e7 /src/tmp.rkt | |
parent | 454f107eee102dde2dbdce81960694c67db6290d (diff) | |
download | december-2022-120f12b197d3a2b9ae0fda4583e5d54b3001ecd7.tar.gz |
back to data diving -- sorting out how to use cond expressions correctly
Diffstat (limited to 'src/tmp.rkt')
-rw-r--r-- | src/tmp.rkt | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/src/tmp.rkt b/src/tmp.rkt index ffb0edb..321226d 100644 --- a/src/tmp.rkt +++ b/src/tmp.rkt @@ -41,28 +41,20 @@ ;; "stats" and "types" AREN'T exactly nested hash tables! They're lists, with hash tables embedded in them! ;; SO! I need a way to test for if something is a LIST, and then if it is a LIST I think then I hash map through that! - -(define (inspector h) - (hash-map h - (lambda (k v) - (if (list? v) (display (~a "HARK! THE VALUE FOR THE KEY ~"k"~ IS A LIST \n====\n")) - (display (~a " key: " k "\nvalue: " v "\n=====\n"))))) - h) - -;;(inspector test-data) - ;; NEXT STEPS -> https://stackoverflow.com/questions/13504302/racket-scheme-filtering ; (hash-ref test-data "stats") ; all stats ; (hash-ref (car (hash-ref test-data "stats")) 'base_stat) ; value for a given stat ; (hash-ref (hash-ref (car (hash-ref test-data "stats")) 'stat) 'name) ; name for a given stat -(define (inspector2 h) + +(define (inspector h) + "display the contents of a hash table for human eyeballs and let the hash table fall back out" (hash-map h (lambda (k v) - (if (list? v) (map - (lambda (x) (inspector2 x)) v) - (display (~a " key: " k "\nvalue: " v "\n=====\n"))))) + (cond [(list? v) (map (lambda (x) (inspector x)) v)] + [(hash? (car (hash-ref v k)) (map (lambda (x) (inspector x)) v))] + [(display (~a " key: " k "\nvalue: " v "\n=====\n"))]))) h) -(inspector2 test-data) +(inspector test-data) |