Created
June 21, 2016 04:57
-
-
Save joemfb/7aeb5e93d1a750d776e3db670ee760c2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :- %say | |
| |= {{@da eny/@uvI beak} $~ $~} | |
| :- %tang =< (to-tang (easy)) | |
| |% | |
| ++ to-tang | |
| |= l/(list tape) | |
| ^- tang | |
| %- flop %+ turn l | |
| |=(t/tape ^-(tank [%leaf t])) | |
| ++ dlists $: | |
| intros/(list tape) | |
| ships/(list tape) | |
| verbs/(list (list tape)) | |
| adjs/(list tape) | |
| nouns/(list (list tape)) | |
| runes/(list (list tape)) | |
| errs/(list tape) | |
| == | |
| ++ get-lists | |
| |= * | |
| ^- dlists | |
| =+ dat=.^(json %cx /=home/348/web/easy/json) | |
| ?> ?=({$o *} dat) | |
| =+ i=(from-array (need (~(get by p.dat) 'intros'))) | |
| =+ s=(from-array (need (~(get by p.dat) 'ships'))) | |
| =+ v=(from-nested-array (need (~(get by p.dat) 'verbs'))) | |
| =+ a=(from-array (need (~(get by p.dat) 'adjectives'))) | |
| =+ n=(from-nested-array (need (~(get by p.dat) 'nouns'))) | |
| =+ r=(from-nested-array (need (~(get by p.dat) 'runes'))) | |
| =+ e=(from-array (need (~(get by p.dat) 'errors'))) | |
| [intros=i ships=s verbs=v adjs=a nouns=n runes=r errs=e] | |
| ++ from-array | |
| |= arr/json | |
| ^- (list tape) | |
| ?> ?=({$a *} arr) | |
| %+ turn p.arr | |
| |=(s/* ?>(?=({$s *} s) (trip (@t +.s)))) | |
| ++ from-nested-array | |
| |= arr/json | |
| ^- (list (list tape)) | |
| ?> ?=({$a *} arr) | |
| %+ turn p.arr | |
| |=(x/json (from-array x)) | |
| ++ get-rands | |
| |= l/dlists | |
| =+ ln=(lent nouns.l) | |
| =+ la=(lent adjs.l) | |
| =+ lr=(lent runes.l) | |
| =+ rng=~(. og eny) | |
| =^ n1 rng (rads:rng ln) | |
| =^ n2 rng (rads:rng ln) | |
| =^ n3 rng (rads:rng ln) | |
| =^ a1 rng (rads:rng la) | |
| =^ a2 rng (rads:rng la) | |
| =^ r1 rng (rads:rng lr) | |
| =^ r2 rng (rads:rng lr) | |
| =^ en rng (rads:rng (lent errs.l)) | |
| =^ e rng (rads:rng 10) | |
| =^ i rng (rads:rng (lent intros.l)) | |
| =^ v rng (rads:rng (lent verbs.l)) | |
| =^ s rng (rads:rng (lent ships.l)) | |
| :* | |
| n=[n1=n1 n2=n2 n3=n3] | |
| a=[a1=a1 a2=a2] | |
| r=[r1=r1 r2=r2] | |
| en=en | |
| e=e | |
| i=i | |
| v=v | |
| s=s | |
| == | |
| ++ article | |
| |= word/tape | |
| ^- tape | |
| =+ h=`@t`(head word) | |
| ?: (~(has in (silt "aeiouh")) h) "an" "a" | |
| ++ plural | |
| |= word/tape | |
| ^- tape | |
| ?: =+ r=`tape`(flop word) | |
| =+ tail=(head r) | |
| =+ tail2=`tape`(swag [0 2] r) | |
| ?|(=('s' tail) =("hs" tail2)) | |
| (weld word "es") | |
| (weld word "s") | |
| ++ plural-if | |
| |= {c/? l/?(tape (list tape))} | |
| ^- tape | |
| ?. ?=({i/{i/* t/*} t/*} l) | |
| =+ l=(tape l) | |
| ?.(c l (plural l)) | |
| =+ l=`(list tape)`l | |
| =+ head=(snag 0 l) | |
| ?. c head | |
| ?: =(2 (lent l)) | |
| (snag 1 l) | |
| (plural head) | |
| ++ strike-if | |
| |= {c/? t/tape} | |
| ^- tape | |
| ?. c t | |
| %- zing %+ turn t | |
| |= x/@ | |
| (tape (limo [x 204 182 ~])) | |
| ++ easy | |
| |= * | |
| ^- (list tape) | |
| =+ l=(get-lists) | |
| =+ rand=(get-rands l) | |
| =+ intro=(snag i.rand intros.l) | |
| =+ ^= third =(0 i.rand) :: TODO: match "Hoon" in tape | |
| =+ verb=(plural-if third (snag v.rand verbs.l)) | |
| =+ adj1=(snag a1.a.rand adjs.l) | |
| =+ adj2=(snag a2.a.rand adjs.l) | |
| =+ noun1=(head (snag n1.n.rand nouns.l)) | |
| =+ noun2=(head (snag n2.n.rand nouns.l)) | |
| =+ noun3=(plural-if & (snag n3.n.rand nouns.l)) | |
| =+ rune1=`(list tape)`(snag r1.r.rand runes.l) | |
| =+ rune2=`(list tape)`(snag r2.r.rand runes.l) | |
| =+ sigil=(weld `tape`(snag 0 rune1) `tape`(snag 0 rune2)) | |
| =+ rune=(weld `tape`(snag 1 rune1) `tape`(snag 1 rune2)) | |
| =+ ship=(snag s.rand ships.l) | |
| =+ err-name=(snag en.rand errs.l) | |
| =+ err=(gth e.rand 6) | |
| =+ prod=(plural-if third "produce") | |
| ::=+ prod="produce" | |
| %- limo | |
| :* | |
| (strike-if err "Urbit is easy! {intro}") | |
| (strike-if err "{verb} {(article noun1)} {noun1} with {(article adj1)} {adj1} {noun2},") | |
| (strike-if err "using the {sigil} ({rune}) twig,") | |
| ?: err | |
| "OH NO! that crashed with {err-name}" | |
| "and {prod} {adj2} {noun3} for {ship}" | |
| ~ | |
| == | |
| -- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment