?@ refactoring

This commit is contained in:
Anton Dyudin 2014-06-06 18:09:44 -07:00 committed by Anton Dyudin
parent 3bb02fe9d7
commit eb79a666a9

View File

@ -409,7 +409,7 @@
[%tree p=term q=wine] ::
[%unit p=term q=wine] ::
== ::
++ wonk |*(veq=edge ?@(q.veq !! p.u.q.veq)) ::
++ wonk |*(veq=edge ?~(q.veq !! p.u.q.veq)) ::
:: ::
:: ::
++ map |* [a=_,* b=_,*] :: associative array
@ -625,7 +625,7 @@
::
++ need :: demand
|* a=(unit)
?@ a
?~ a
!!
u.a
::
@ -642,7 +642,7 @@
^+ a
=+ b=`_a`~
|-
?@ a
?~ a
b
$(a t.a, b [i.a b])
::
@ -656,7 +656,7 @@
++ limo :: listify
|* a=*
^+ =< $
|% +- $ ?@(a ~ ?:(_? [i=-.a t=$] $(a +.a)))
|% +- $ ?~(a ~ ?:(_? [i=-.a t=$] $(a +.a)))
--
a
::
@ -666,13 +666,13 @@
^- @
=+ b=0
|-
?@(a b $(a t.a, b +(b)))
?~(a b $(a t.a, b +(b)))
::
++ levy
~/ %levy :: all of
|* [a=(list) b=_|=(p=* .?(p))]
|- ^- ?
?@ a
?~ a
&
?: (b i.a)
$(a t.a)
@ -690,7 +690,7 @@
~/ %reel
|* [a=(list) b=_=|([p=* q=*] |.(q))]
|- ^+ q.b
?@ a
?~ a
q.b
(b i.a $(a t.a))
::
@ -699,7 +699,7 @@
|* [a=(list) b=_=|([p=* q=*] |.(q))]
|-
^+ q.b
?@ a
?~ a
q.b
$(a t.a, b b(q (b i.a q.b)))
::
@ -715,7 +715,7 @@
|* [a=(list) b=_|=(p=* .?(p))]
|-
^+ a
?@ a
?~ a
~
?:((b i.a) [i.a $(a t.a)] $(a t.a))
::
@ -724,7 +724,7 @@
|* [a=(list) b=_|=(p=* .?(p))]
|-
^+ a
?@ a
?~ a
~
?:((b i.a) $(a t.a) [i.a $(a t.a)])
::
@ -742,7 +742,7 @@
|- ^+ b
?: =(0 a)
b
?@ b
?~ b
~
$(b t.b, a (dec a))
::
@ -775,7 +775,7 @@
~/ %turn
|* [a=(list) b=_,*]
|-
?@ a
?~ a
~
[i=(b i.a) t=$(a t.a)]
::
@ -879,7 +879,7 @@
~/ %rap
|= [a=bloq b=(list ,@)]
^- @
?@ b
?~ b
0
(cat a i.b $(b t.b))
::
@ -889,7 +889,7 @@
^- @
=+ c=0
|-
?@ b
?~ b
0
(con (lsh a c (end a 1 i.b)) $(c +(c), b t.b))
::
@ -1575,10 +1575,10 @@
::
++ apt :: set invariant
|= a=(tree)
?@ a
?~ a
&
?& ?@(l.a & ?&((vor n.a n.l.a) (hor n.l.a n.a)))
?@(r.a & ?&((vor n.a n.r.a) (hor n.a n.r.a)))
?& ?~(l.a & ?&((vor n.a n.l.a) (hor n.l.a n.a)))
?~(r.a & ?&((vor n.a n.r.a) (hor n.a n.r.a)))
==
::
++ in :: set engine
@ -1588,7 +1588,7 @@
~/ %all
|* b=$+(* ?)
|- ^- ?
?@ a
?~ a
&
?&((b n.a) $(a l.a) $(a r.a))
::
@ -1596,7 +1596,7 @@
~/ %any
|* b=$+(* ?)
|- ^- ?
?@ a
?~ a
|
?|((b n.a) $(a l.a) $(a r.a))
::
@ -1631,7 +1631,7 @@
~/ %gas
|= b=(list ,_?>(?=(^ a) n.a))
|- ^+ a
?@ b
?~ b
a
$(b t.b, a (put(+< a) i.b))
::
@ -1639,7 +1639,7 @@
~/ %has
|* b=*
|- ^- ?
?@ a
?~ a
|
?: =(b n.a)
&
@ -1651,7 +1651,7 @@
~/ %put
|* b=*
|- ^+ a
?@ a
?~ a
[b ~ ~]
?: =(b n.a)
a
@ -1677,7 +1677,7 @@
~/ %tap
|= b=(list ,_?>(?=(^ a) n.a))
^+ b
?@ a
?~ a
b
$(a r.a, b [n.a $(a l.a)])
::
@ -1691,10 +1691,10 @@
::
++ ept :: map invariant
|= a=(tree ,[p=* q=*])
?@ a
?~ a
&
?& ?@(l.a & ?&((vor p.n.a p.n.l.a) (hor p.n.l.a p.n.a)))
?@(r.a & ?&((vor p.n.a p.n.r.a) (hor p.n.a p.n.r.a)))
?& ?~(l.a & ?&((vor p.n.a p.n.l.a) (hor p.n.l.a p.n.a)))
?~(r.a & ?&((vor p.n.a p.n.r.a) (hor p.n.a p.n.r.a)))
==
::
++ ja :: jar engine
@ -1736,7 +1736,7 @@
~/ %all
|* b=$+(* ?)
|- ^- ?
?@ a
?~ a
&
?&((b q.n.a) $(a l.a) $(a r.a))
::
@ -1744,7 +1744,7 @@
~/ %any
|* b=$+(* ?)
|- ^- ?
?@ a
?~ a
|
?|((b q.n.a) $(a l.a) $(a r.a))
::
@ -1780,7 +1780,7 @@
|* b=(list ,[p=* q=*])
=> .(b `(list ,_?>(?=(^ a) n.a))`b)
|- ^+ a
?@ b
?~ b
a
$(b t.b, a (put(+< a) p.i.b q.i.b))
::
@ -1788,7 +1788,7 @@
~/ %get
|* b=*
|- ^- ?(~ [~ u=_?>(?=(^ a) q.n.a)])
?@ a
?~ a
~
?: =(b p.n.a)
[~ u=q.n.a]
@ -1811,7 +1811,7 @@
~/ %put
|* [b=* c=*]
|- ^+ a
?@ a
?~ a
[[b c] ~ ~]
?: =(b p.n.a)
?: =(c q.n.a)
@ -1855,14 +1855,14 @@
~/ %tap
|= b=(list ,_?>(?=(^ a) n.a))
^+ b
?@ a
?~ a
b
$(a r.a, b [n.a $(a l.a)])
::
+- uni :: union, merge
~/ %uni
|= b=_a
?@ b a
?~ b a
%= $
a (~(put by a) p.n.b q.n.b)
b (~(uni by l.b) r.b)
@ -1989,7 +1989,7 @@
=< q
|- ^- [p=@ q=@ r=_m]
=+ c=(~(get by m) a)
?@ c
?~ c
=> .(m (~(put by m) a b))
?: ?=(@ a)
=+ d=(mat a)
@ -2051,7 +2051,7 @@
~/ %fun
|= tub=nail
=+ vex=(sef tub)
?@ q.vex
?~ q.vex
vex
[p=p.vex q=[~ u=[p=cus q=q.u.q.vex]]]
::
@ -2061,7 +2061,7 @@
~/ %fun
|= tub=nail
=+ vex=(sef tub)
?@ q.vex
?~ q.vex
vex
[p=p.vex q=[~ u=[p=(poq p.u.q.vex) q=q.u.q.vex]]]
::
@ -2078,7 +2078,7 @@
|* sef=_rule
|= tub=nail
=+ vex=(sef tub)
?@(q.vex vex ?:(=(~ q.q.u.q.vex) vex [p=p.vex q=~]))
?~(q.vex vex ?:(=(~ q.q.u.q.vex) vex [p=p.vex q=~]))
::
++ funk :: add to tape first
|* [pre=tape sef=_rule]
@ -2091,7 +2091,7 @@
~/ %fun
|= tub=nail
=+ vex=(sef tub)
?@ q.vex
?~ q.vex
vex
[p=p.vex q=[~ u=[p=(hez [p.tub p.q.u.q.vex] p.u.q.vex) q=q.u.q.vex]]]
::
@ -2112,7 +2112,7 @@
~/ %fun
|= tub=nail
^- (like char)
?@ q.tub
?~ q.tub
(fail tub)
?. =(daf i.q.tub)
(fail tub)
@ -2130,7 +2130,7 @@
~/ %fun
|= tub=nail
^- (like char)
?@ q.tub
?~ q.tub
(fail tub)
?. (lien bud |=(a=char =(i.q.tub a)))
(fail tub)
@ -2139,7 +2139,7 @@
++ next :: consume a char
|= tub=nail
^- (like char)
?@ q.tub
?~ q.tub
(fail tub)
=+ zac=(lust i.q.tub p.tub)
[zac [~ i.q.tub [zac t.q.tub]]]
@ -2150,10 +2150,10 @@
~/ %fun
|= tub=nail
=+ vex=(sef tub)
?@ q.vex
?~ q.vex
vex
=+ gey=(pyq p.u.q.vex)
?@ gey
?~ gey
[p=p.vex q=~]
[p=p.vex q=[~ u=[p=u.gey q=q.u.q.vex]]]
::
@ -2163,7 +2163,7 @@
~/ %fun
|= tub=nail
^- (like char)
?@ q.tub
?~ q.tub
(fail tub)
?. ?&((gte i.q.tub les) (lte i.q.tub mos))
(fail tub)
@ -2175,7 +2175,7 @@
~/ %fun
|= tub=nail
=+ vex=(sef tub)
?@ q.vex
?~ q.vex
vex
[p=p.vex q=[~ u=[p=[gob p.u.q.vex] q=q.u.q.vex]]]
::
@ -2216,10 +2216,10 @@
[n.nuc [n.yal l.yal l.nuc] r.nuc]
~% %fun ..^$ ~
|= tub=nail
?@ q.tub
?~ q.tub
(fail tub)
|-
?@ hel
?~ hel
(fail tub)
?: ?@ p.n.hel
=(p.n.hel i.q.tub)
@ -2237,7 +2237,7 @@
|= tub=nail
^- (like ,_rud)
=+ vex=(fel tub)
?@ q.vex
?~ q.vex
[p.vex [~ rud tub]]
=+ wag=$(tub q.u.q.vex)
?> ?=(^ q.wag)
@ -2252,7 +2252,7 @@
?: =(0 mos)
[p.tub [~ ~ tub]]
=+ vex=(fel tub)
?@ q.vex
?~ q.vex
?: =(0 les)
[p.vex [~ ~ tub]]
vex
@ -2261,7 +2261,7 @@
mos ?:(=(0 mos) 0 (dec mos))
tub q.u.q.vex
==
?@ q.wag
?~ q.wag
wag
[p.wag [~ [p.u.q.vex p.u.q.wag] q.u.q.wag]]
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@ -2272,11 +2272,11 @@
|* raq=_|*([a=* b=*] [~ u=[a b]])
~/ %fun
|* [vex=edge sab=_rule]
?@ q.vex
?~ q.vex
vex
=+ yit=(sab q.u.q.vex)
=+ yur=(last p.vex p.yit)
?@ q.yit
?~ q.yit
[p=yur q=q.vex]
=+ vux=(raq p.u.q.vex p.u.q.yit)
?~ vux
@ -2288,11 +2288,11 @@
|* raq=_|*([a=* b=*] [a b]) :: arbitrary compose
~/ %fun
|* [vex=edge sab=_rule]
?@ q.vex
?~ q.vex
vex
=+ yit=(sab q.u.q.vex)
=+ yur=(last p.vex p.yit)
?@ q.yit
?~ q.yit
[p=yur q=q.yit]
[p=yur q=[~ u=[p=(raq p.u.q.vex p.u.q.yit) q=q.u.q.yit]]]
::
@ -2310,18 +2310,18 @@
++ plug :: first then second
~/ %plug
|* [vex=edge sab=_rule]
?@ q.vex
?~ q.vex
vex
=+ yit=(sab q.u.q.vex)
=+ yur=(last p.vex p.yit)
?@ q.yit
?~ q.yit
[p=yur q=q.yit]
[p=yur q=[~ u=[p=[p.u.q.vex p.u.q.yit] q=q.u.q.yit]]]
::
++ pose :: first or second
~/ %pose
|* [vex=edge sab=_rule]
?@ q.vex
?~ q.vex
=+ roq=(sab)
[p=(last p.vex p.roq) q=q.roq]
vex
@ -2474,7 +2474,7 @@
|= tub=nail
^- (like axis)
=+ vex=?:(hom (bet tub) (gul tub))
?@ q.vex
?~ q.vex
[p.tub [~ 1 tub]]
=+ wag=$(p.tub p.vex, hom !hom, tub q.u.q.vex)
?> ?=(^ q.wag)
@ -2498,7 +2498,7 @@
?~(q.vex ~ [~ u=p.u.q.vex])
++ scan |* [los=tape sab=_rule]
=+ vex=((full sab) [[1 1] los])
?@ q.vex
?~ q.vex
~_ (show [%m '{%d %d}'] p.p.vex q.p.vex ~)
~|('syntax-error' !!)
p.u.q.vex
@ -2519,7 +2519,7 @@
++ mesc
|= vib=tape
^- tape
?@ vib
?~ vib
~
?: =('\\' i.vib)
['\\' '\\' $(vib t.vib)]
@ -2578,7 +2578,7 @@
++ trim
|= [a=@ b=tape]
^- [p=tape q=tape]
?@ b
?~ b
[~ ~]
?: =(0 a)
[~ b]
@ -2760,10 +2760,10 @@
%+ weld
q.p.tac
|- ^- tape
?@ q.tac
?~ q.tac
r.p.tac
=+ voz=$(q.tac t.q.tac)
(weld ram(tac i.q.tac) ?@(t.q.tac voz (weld p.p.tac voz)))
(weld ram(tac i.q.tac) ?~(t.q.tac voz (weld p.p.tac voz)))
==
::
++ win
@ -2775,15 +2775,15 @@
%palm
?: fit
(rig ram)
?@ q.tac
?~ q.tac
(rig q.p.tac)
?@ t.q.tac
?~ t.q.tac
(rig(tab (add 2 tab), lug $(tac i.q.tac)) q.p.tac)
=> .(q.tac `(list tank)`q.tac)
=+ lyn=(mul 2 (lent q.tac))
=+ ^= qyr
|- ^- wall
?@ q.tac
?~ q.tac
lug
%= ^$
tac i.q.tac
@ -2797,7 +2797,7 @@
(rig ram)
=+ ^= gyl
|- ^- wall
?@ q.tac
?~ q.tac
?:(=(%$ r.p.tac) lug (rig r.p.tac))
^$(tac i.q.tac, lug $(q.tac t.q.tac), tab din)
?: =(%$ q.p.tac)
@ -2817,7 +2817,7 @@
:- (runt [(sub tab 2) ' '] ['\\' '/' (weld p.mut `_hom`['\\' '/' ~])])
=> .(hom q.mut)
|-
?@ hom
?~ hom
:- %+ runt
[(sub tab 2) ' ']
['\\' '/' (runt [(sub edg tab) ' '] ['\\' '/' ~])]
@ -2828,15 +2828,15 @@
++ wig
|= hom=tape
^- wall
?@ lug
?~ lug
(rig hom)
=+ lin=(lent hom)
=+ wug=:(add 1 tab lin)
?. =+ mir=i.lug
|- ?@ mir
|- ?~ mir
|
?|(=(0 wug) ?&(=(' ' i.mir) $(mir t.mir, wug (dec wug))))
(rig hom)
(rig hom) :: ^ XX regular form?
[(runt [tab ' '] (weld hom `tape`[' ' (slag wug i.lug)])) t.lug]
--
--
@ -3275,7 +3275,7 @@
++ slay
|= txt=@ta ^- (unit coin)
=+ vex=((full nuck:so) [[1 1] (trip txt)])
?@ q.vex
?~ q.vex
~
[~ p.u.q.vex]
::
@ -3291,7 +3291,7 @@
|= [a=tape] :: parse tape to rege
^- (unit rege)
=+ foo=((full anns) [[1 1] a])
?@ q.foo
?~ q.foo
~
[~ p.u.q.foo]
::
@ -5846,7 +5846,7 @@
::
[%fern *]
|- ^- twig
?@ t.p.sec
?~ t.p.sec
^$(sec i.p.sec)
[%wtcl [%bczp %bean] ^$(sec i.p.sec) $(p.sec t.p.sec)]
::
@ -5855,7 +5855,7 @@
::
[%kelp *]
|- ^- twig
?@ t.p.sec
?~ t.p.sec
^$(sec i.p.sec)
[%wtcl [%bczp %bean] ^$(sec i.p.sec) $(p.sec t.p.sec)]
::
@ -5939,7 +5939,7 @@
::
[%fern *]
|- ^- twig
?@ t.p.sec
?~ t.p.sec
^$(sec i.p.sec)
:+ %tsls
^$(sec i.p.sec)
@ -5955,7 +5955,7 @@
[%kelp *]
%- tun |= gon=* => .(nag gon)
|- ^- twig
?@ t.p.sec
?~ t.p.sec
:- [%dtzz +.p.i.p.sec]
^^$(axe (peg axe 3), sec q.i.p.sec, nag &)
:^ %wtcl
@ -6105,7 +6105,7 @@
:- %clsg
=+ nob=`(list twig)`~
|- ^- (list twig)
?@ r.gen
?~ r.gen
nob
[[[%dtzz %$ p.i.r.gen] [%zpts q.i.r.gen]] $(r.gen t.r.gen)]
s.gen
@ -6248,7 +6248,7 @@
::
[%wtbr *]
|-
?@(p.gen [%dtzz %f 1] [%wtcl i.p.gen [%dtzz %f 0] $(p.gen t.p.gen)])
?~(p.gen [%dtzz %f 1] [%wtcl i.p.gen [%dtzz %f 0] $(p.gen t.p.gen)])
::
[%wtdt *] [%wtcl p.gen r.gen q.gen]
[%wtgl *] [%wtcl p.gen [%zpzp ~] q.gen]
@ -6256,7 +6256,7 @@
[%wtkt *] [%wtcl [%wtts [%axil %atom %$] p.gen] r.gen q.gen]
[%wthp *]
|-
?@ q.gen
?~ q.gen
[%zpfs [%cnzz p.gen]]
:^ %wtcl
[%wtts p.i.q.gen p.gen]
@ -6266,7 +6266,7 @@
[%wtls *] [%wthp p.gen (weld r.gen `_r.gen`[[[%axil %noun] q.gen] ~])]
[%wtpm *]
|-
?@(p.gen [%dtzz %f 0] [%wtcl i.p.gen $(p.gen t.p.gen) [%dtzz %f 1]])
?~(p.gen [%dtzz %f 0] [%wtcl i.p.gen $(p.gen t.p.gen) [%dtzz %f 1]])
::
[%wtpt *] [%wtcl [%wtts [%axil %atom %$] p.gen] q.gen r.gen]
[%wtsg *] [%wtcl [%wtts [%axil %null] p.gen] q.gen r.gen]
@ -6619,8 +6619,8 @@
:+ %rose
[['/' ~] ['/' ~] ~]
|- ^- (list tank)
?@ lum
?>(?=(~ lum) ~)
?~ lum ~
?@ lum !!
?> ?=(@ -.lum)
[[%leaf (rip 3 -.lum)] $(lum +.lum)]
::
@ -6633,8 +6633,8 @@
:+ %rose
[[' ' ~] ['<' '|' ~] ['|' '>' ~]]
|- ^- (list tank)
?@ lum
?>(?=(~ lum) ~)
?~ lum ~
?@ lum !!
[[%leaf (trip ((hard ,@) -.lum))] $(lum +.lum)]
::
%wool
@ -6642,8 +6642,8 @@
:+ %rose
[[' ' ~] ['<' '<' ~] ['>' '>' ~]]
|- ^- (list tank)
?@ lum
?>(?=(~ lum) ~)
?~ lum ~
?@ lum !!
[(need ^$(q.ham %yarn, lum -.lum)) $(lum +.lum)]
::
%yarn
@ -7161,7 +7161,7 @@
=+ goy=(~(tap by rud) ~)
=+ waf=dab
|- ^+ dab
?@ goy
?~ goy
waf
~| [%hang-on p.i.goy]
=+ yeq=(~(get by dab) p.i.goy)
@ -7450,7 +7450,7 @@
=- [(nice (fire p.yom)) (fire(vet |) q.yom)]
^= yom
|- ^- [p=(list ,[p=type q=foot]) q=(list ,[p=type q=foot])]
?@ mew
?~ mew
[q.q.lar q.q.vug]
=+ zil=^$(gen q.i.mew, gol %noun)
=+ cuf=(tock p.i.mew p.zil q.q.lar)
@ -7814,7 +7814,7 @@
=+ rag=q.q.lar
%- fire
|- ^- (list ,[p=type q=foot])
?@ mew
?~ mew
rag
$(mew t.mew, rag q:(tock p.i.mew ^$(gen q.i.mew) rag))
[%dtkt *] %noun
@ -7966,7 +7966,7 @@
=- [(need p.wib) q.wib]
^= wib
|- ^- [p=(unit axis) q=(list ,[p=type q=foot])]
?@ men
?~ men
[*(unit axis) ~]
=+ geq=(tack(sut p.i.men) peh mur)
=+ mox=$(men t.men)