about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--log.txt1
-rw-r--r--src/pokedex.rkt33
-rw-r--r--src/tmp.rkt2
3 files changed, 19 insertions, 17 deletions
diff --git a/log.txt b/log.txt
index 38c1875..3d3a713 100644
--- a/log.txt
+++ b/log.txt
@@ -3,3 +3,4 @@
 02 DEC: Added a function to grab only the data I'll need for the pokedex entry, and add it all to a hash table for later use
 03 DEC: Going *deep* on how best to handle hash table data -- not lots of visible progress, but lots of noodling [late night addition -- cracked the nut!]
 04 DEC: Today a lot of noodling and toodling with recursion. Exploring ways to map/filter/for-each over the data to access what I am after
+05 DEC: No huge progress to share -- explored a few other implementations of scheme and interface options, pausing on data (re)shaping and wrangling
diff --git a/src/pokedex.rkt b/src/pokedex.rkt
index 67710f6..d8830c6 100644
--- a/src/pokedex.rkt
+++ b/src/pokedex.rkt
@@ -1,3 +1,4 @@
+
 #lang racket
 
 ;; let's try to make a pokedex in racket!
@@ -14,8 +15,9 @@
 ;; basic GET request
 (require net/url)
 (require json)
-; (require nested-hash) ;; this hasn't helped me with anything yet...
 
+; 🤔
+(require slideshow/pict racket/draw)
 
 ;; API URL
 (define *POKE-API* "https://pokeapi.co/api/v2/")
@@ -25,7 +27,7 @@
     "queries the api, returns a butt ton of info"
 	(call/input-url (string->url (~a *POKE-API* "pokemon/" id)) ; ~a, like string-append but appends *either* strings or numbers to a string
                 get-pure-port
-                (compose string->jsexpr port->string))) ;; QUESTION: could I use read-json here, instead?
+                (compose string->jsexpr port->string))) ; QUESTION: could I use read-json here, instead?
 
 (define (dex-entry id)
     "selects the info we need from the api, builds a hash table of the data that will build the entry"
@@ -38,21 +40,20 @@
         (hash-set! entry-data "types" (hash-ref poke-data 'types))
         entry-data))
 
-; (dex-entry 12) ;; QUESTION: would this all be easier to handle if it were a vector or list instead of a hash table?
-
-;; 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 and let the hash table fall back out"
-    (hash-map h
-        (lambda (k v)
-          (if (hash? v) (~a "value " v " was a hash table!\n") ;; test to see if a value is a hash table
-            (display (~a "key: " k ", value: " v "\n")))) ; QUESTION: is there a functional difference between hash-map and hash-for-each here?
-    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 ; consider making this if a cond and testing for lists/hash tables to recursively dive into nested data
+                             (lambda (x) (inspector x)) v)
+                  (display (~a "  key: " k "\nvalue: " v "\n=====\n")))))
+  h)
 
-; (hash-ref (dex-entry 5) "types") ;; struggling to figure out how to access the nested hash tables stats and types...
+(inspector (dex-entry 11))
+(inspector (dex-entry "bulbasaur"))
 
-;; 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.
+(define img (hash-ref (dex-entry 11) "sprite"))
 
-(inspector (dex-entry 11))
+(define display-image (bitmap (make-object bitmap% img)))
+
+(frame (scale display-image 0.3))
diff --git a/src/tmp.rkt b/src/tmp.rkt
index 08cd3fd..ffb0edb 100644
--- a/src/tmp.rkt
+++ b/src/tmp.rkt
@@ -61,7 +61,7 @@
   (hash-map h
             (lambda (k v)
               (if (list? v) (map
-                             (lambda (x) (inspector2 x)) v)                
+                             (lambda (x) (inspector2 x)) v)               
                   (display (~a "  key: " k "\nvalue: " v "\n=====\n")))))
   h)