mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-01 11:33:41 +03:00
factor out map-to-json
This commit is contained in:
parent
73bcc66007
commit
bf2164054d
8
lib/map-to-json.hoon
Normal file
8
lib/map-to-json.hoon
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
:: hoon data to json
|
||||||
|
::
|
||||||
|
:::: /hoon/map-to-json/lib
|
||||||
|
::
|
||||||
|
/? 310
|
||||||
|
|* {a/_cord b/_json} :: XX {a/$-(* cord) b/$-(* json)}
|
||||||
|
|= c/(map _+<.a _+<.b)
|
||||||
|
(jobe (turn (~(tap by c)) |*(d/^ [(a -.d) (b +.d)])))
|
@ -12,12 +12,6 @@
|
|||||||
~[ele]
|
~[ele]
|
||||||
(zing (turn c.ele ..$))
|
(zing (turn c.ele ..$))
|
||||||
::
|
::
|
||||||
++ map-to-json :: hoon data to json
|
|
||||||
|* {a/$-(* cord) b/$-(* json)}
|
|
||||||
|* c/(map) ^- json :: XX c=(map _+<.a _+<.b)
|
|
||||||
~! c
|
|
||||||
(jobe (turn (~(tap by c)) |*(* [(a +<-) (b +<+)])))
|
|
||||||
::
|
|
||||||
:: a.b_c.d => [[%a %b] [%c %d]]
|
:: a.b_c.d => [[%a %b] [%c %d]]
|
||||||
:: a.b_c, a_b__c => [[%a %b] %c]
|
:: a.b_c, a_b__c => [[%a %b] %c]
|
||||||
:: a_b_c, a__b_c => [%a [%b %c]]
|
:: a_b_c, a__b_c => [%a [%b %c]]
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
::
|
::
|
||||||
/? 310
|
/? 310
|
||||||
/- talk
|
/- talk
|
||||||
/+ talk
|
/+ talk,map-to-json
|
||||||
!:
|
!:
|
||||||
=+ talk
|
=+ talk
|
||||||
|_ gam/(list telegram)
|
|_ gam/(list telegram)
|
||||||
@ -127,20 +127,12 @@
|
|||||||
++ jope |=(a/ship (jape +:<a>)) ::[%s (crip +:(scow %p a))])
|
++ jope |=(a/ship (jape +:<a>)) ::[%s (crip +:(scow %p a))])
|
||||||
++ joke |=(a/tank [%s (role (turn (wash 0^80 a) crip))])
|
++ joke |=(a/tank [%s (role (turn (wash 0^80 a) crip))])
|
||||||
++ jode |=(a/time (jone (div (mul (sub a ~1970.1.1) 1.000) ~s1)))
|
++ jode |=(a/time (jone (div (mul (sub a ~1970.1.1) 1.000) ~s1)))
|
||||||
++ jome :: stringify keys
|
|
||||||
|* {a/_cord b/_json}
|
|
||||||
|= c/(map _+<.a _+<.b)
|
|
||||||
(jobe (turn (~(tap by c)) (both a b)))
|
|
||||||
::
|
|
||||||
++ both :: cons two gates
|
|
||||||
|* {a/_* b/_*}
|
|
||||||
|=(c/_[+<.a +<.b] [(a -.c) (b +.c)])
|
|
||||||
::
|
::
|
||||||
++ thot
|
++ thot
|
||||||
|= thought
|
|= thought
|
||||||
(jobe serial+(jape <p>) audience+(audi q) statement+(stam r) ~)
|
(jobe serial+(jape <p>) audience+(audi q) statement+(stam r) ~)
|
||||||
::
|
::
|
||||||
++ audi (jome parn jove)
|
++ audi (map-to-json parn jove)
|
||||||
++ bouq
|
++ bouq
|
||||||
|= a/bouquet
|
|= a/bouquet
|
||||||
a+(turn (~(tap in a)) |=(b/path a+(turn b |=(c/knot s+c))))
|
a+(turn (~(tap in a)) |=(b/path a+(turn b |=(c/knot s+c))))
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
:::: /hoon/index/tree/mar
|
:::: /hoon/index/tree/mar
|
||||||
::
|
::
|
||||||
/? 310
|
/? 310
|
||||||
/+ tree,react
|
/+ tree,react,map-to-json
|
||||||
[. tree react]
|
[. tree react]
|
||||||
!:
|
!:
|
||||||
::::
|
::::
|
||||||
|
Loading…
Reference in New Issue
Block a user