about summary refs log blame commit diff stats
path: root/src/tmp.rkt
blob: b10d3b18542650ecb1bde2cb270e9304bc41cae4 (plain) (tree)
1
2
3


                                    


























                                                                                                     





                                                                                                       

                                                                      




                                                                    

                                                                               


                        
#lang racket

(define test-data '#hash(("id" . 12)
       ("name" . "butterfree")
       ("sprite" . "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/12.png")
       ("stats"
        . (#hasheq((base_stat . 60)
                   (effort . 0)
                   (stat . #hasheq((name . "hp") (url . "https://pokeapi.co/api/v2/stat/1/"))))
           #hasheq((base_stat . 45)
                   (effort . 0)
                   (stat . #hasheq((name . "attack") (url . "https://pokeapi.co/api/v2/stat/2/"))))
           #hasheq((base_stat . 50)
                   (effort . 0)
                   (stat . #hasheq((name . "defense") (url . "https://pokeapi.co/api/v2/stat/3/"))))
           #hasheq((base_stat . 90)
                   (effort . 2)
                   (stat . #hasheq((name . "special-attack")
                                   (url . "https://pokeapi.co/api/v2/stat/4/"))))
           #hasheq((base_stat . 80)
                   (effort . 1)
                   (stat . #hasheq((name . "special-defense")
                                   (url . "https://pokeapi.co/api/v2/stat/5/"))))
           #hasheq((base_stat . 70)
                   (effort . 0)
                   (stat . #hasheq((name . "speed") (url . "https://pokeapi.co/api/v2/stat/6/"))))))
       ("types"
        . (#hasheq((slot . 1)
                   (type . #hasheq((name . "bug") (url . "https://pokeapi.co/api/v2/type/7/"))))
           #hasheq((slot . 2)
                   (type . #hasheq((name . "flying") (url . "https://pokeapi.co/api/v2/type/3/"))))))))


(define (inspector1 h)
    (hash-map h
        (lambda (k v)
                (display (~a "  key: " k "\nvalue: " v "\n=====\n"))))
    h)

(define (inspector2 h)
    (hash-map h
        (lambda (k v)
                (if (hash? v) (~a "value " v " was a hash table!\n")
                        (display (~a "  key: " k "\nvalue: " v "\n=====\n")))))
    h)

; (inspector1 test-data)
(inspector2 test-data)