diff options
author | elioat <elioat@tilde.institute> | 2022-12-02 14:24:14 -0500 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2022-12-02 14:24:14 -0500 |
commit | 32a3bfef3e4307a80e83aa8be825f9e9240124f5 (patch) | |
tree | a7f65ee8ad2a8119d53e682731e294260d39e896 | |
parent | 4fcc89ecea9437d578ce34d1fe1543edfb8f099c (diff) | |
download | december-2022-32a3bfef3e4307a80e83aa8be825f9e9240124f5.tar.gz |
Exploring nested-hashtables
-rw-r--r-- | log.txt | 3 | ||||
-rw-r--r-- | src/pokedex.rkt | 6 |
2 files changed, 8 insertions, 1 deletions
diff --git a/log.txt b/log.txt index 10d00cb..39a7d57 100644 --- a/log.txt +++ b/log.txt @@ -1,2 +1,3 @@ 30 NOV: Came up with the idea to do December Adventure, bootstrapped this repo -01 DEC: Played with vector sorting and summing in APL. Wrote function to fetch data from pokeapi, and return data as s-expression. Explored racket fmt utility \ No newline at end of file +01 DEC: Played with vector sorting and summing in APL. Wrote function to fetch data from pokeapi, and return data as s-expression. Explored racket fmt utility +02 DEC: \ No newline at end of file diff --git a/src/pokedex.rkt b/src/pokedex.rkt index d710758..16f59c0 100644 --- a/src/pokedex.rkt +++ b/src/pokedex.rkt @@ -14,6 +14,7 @@ ;; basic GET request (require net/url) (require json) +(require nested-hash) ;; package that makes traversing nested hash tables a wee bit easier ;; API URL (define *POKE-API* "https://pokeapi.co/api/v2/pokemon/") @@ -30,3 +31,8 @@ ;; (get-pokemon "ditto") ;; (get-pokemon 123) + +(define poke-data (get-pokemon 123)) + +(nested-hash-ref poke-data 'name) ;; this will return "scyther" +(nested-hash-ref poke-data 'id) ;; this will return 123 \ No newline at end of file |