diff options
Diffstat (limited to 'src')
-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) |