From 507d5b8606437b269f14c869beded7b87b9d0d9b Mon Sep 17 00:00:00 2001 From: elioat Date: Sat, 3 Dec 2022 13:19:25 -0500 Subject: saaaaaaaaaaaaaaand box --- src/pokedex.rkt | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/pokedex.rkt b/src/pokedex.rkt index 89fd7ea..cc48fba 100644 --- a/src/pokedex.rkt +++ b/src/pokedex.rkt @@ -43,23 +43,13 @@ ;; TOMORROW I'll start to figure out how to present this data (define (inspector h) - "display the contents of a hash table for human eyeballs" + "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 (hash? v) (inspector v) ;; test if value is a hash table, if so recursively apply inspector (I don't think this is working right) - (display (~a "key: " k ", value: " v "\n"))))) ; QUESTION: is there a functional difference between hash-map and hash-for-each here? + (display (~a "key: " k ", value: " v "\n")))) ; QUESTION: is there a functional difference between hash-map and hash-for-each here? h) -; the sketch of how maybe to access these nested hash tables (this has become hillariously difficult to solve) -; (define path '(some deep key)) -> - -; (for/fold ((ht deep-hash-table)) -; ((key (in-list path)) -; #:break -; (not (hash? ht))) -; (hash-ref ht key)) - -(hash-ref (inspector (dex-entry 5)) "types") ;; struggling to figure out how to access the nested hash tables stats and types... +(hash-ref (dex-entry 5) "types") ;; struggling to figure out how to access the nested hash tables stats and types... ;; the other option not yet considered is to make individual API calls for each bit of data, rather than 1 call and plucking out the data I want. ;; this may lead to an easier data shape, but means a lot more network traffic. -- cgit 1.4.1-2-gfad0