Sfoglia il codice sorgente

week5 is hard

master
Thorn Avery 4 anni fa
parent
commit
f116fd9bab
1 ha cambiato i file con 52 aggiunte e 0 eliminazioni
  1. +52
    -0
      201/week5/poke.hoon

+ 52
- 0
201/week5/poke.hoon Vedi File

@@ -0,0 +1,53 @@
/+ tapp, stdio
::
=>
|%
+$ state
$: pokedex=(map cord json)
==
+$ peek-data _!!
+$ in-poke-data [%noun =cord]
+$ out-poke-data ~
+$ in-peer-data ~
+$ out-peer-data
$% [%pokemon json]
==
++ tapp (^tapp state peek-data in-poke-data out-poke-data in-peer-data out-peer-data)
++ stdio (^stdio out-poke-data out-peer-data)
--
=>
|%
++ comment-to-tang
|= =tape
^- tang
%+ welp
%+ turn (rip 10 (crip tape))
|= line=cord
leaf+(trip line)
[leaf+""]~
++ urls
=/ base "https://pokeapi.co/api/v2/"
:* pokemon=(weld base "pokemon/")
==
--
=, async=async:tapp
=, tapp-async=tapp-async:tapp
=, stdio
::
%- create-tapp-poke-peer-take:tapp
^- tapp-core-poke-peer-take:tapp
|_ [=bowl:gall state]
::
|= =in-poke-data
=/ m tapp-async
=/ pokename cord.in-poke-data
^- form:m
::
?: (~(has by state) pokename)
~& 'pokemon already caught'
(pure:m (~(got by state) pokename))
=/ pokeurl (weld pokemon:urls (trip pokename))
%+ (set-timeout _json) (add now.bowl ~s15)
;< =json bind:m (fetch-json pokeurl)


Loading…
Annulla
Salva