More constant-folding cleanups.

This commit is contained in:
C. Guy Yarvin 2017-12-15 18:41:44 -08:00
parent 35fb2545ab
commit ae7f263a43
6 changed files with 33 additions and 30 deletions

View File

@ -7552,7 +7552,6 @@
{$bckt *} [%vine boil(gen p.gen) boil(gen q.gen)]
{$bchp *}
:- %weed
:- %cold
:+ %tsgr
:- [%tsgr p.gen [%limb %$]]
[%tsgr q.gen [%limb %$]]

View File

@ -35,7 +35,8 @@
|= [new=deyd old=deyd]
^- $&
?> (melt new old)
?> =((shaf %meld (sham q.new)) (need (sure:as:(com:nu:crub:crypto r.q.old) *code p.new)))
?> .= (shaf %meld (sham q.new))
(need (sure:as:(com:nu:crub:crypto r.q.old) *code p.new))
%&
::
++ melt :: proper connect
@ -643,7 +644,7 @@
~(. lax [her ?~(fod (gur her) u.fod)])
::
++ nux :: install dore
|= new=_lax
|: new=lax
^+ +>
+>(hoc.saf (~(put by hoc.saf) her.new dur.new))
::
@ -709,7 +710,7 @@
==
::
++ su :: install safe
|= new=_as
|: new=as
^- town
ton(urb (~(put by urb.ton) our.new saf.new))
::

View File

@ -36,11 +36,13 @@
tym
::
++ up :: priority queue
:: xx this is ugly old hoon and needs to be modernized
::
=+ [key=@da val=duct]
=+ cmp=lte :: lte=min, gte=max
=> |%
++ link
|= {p/(sqeu key val) q/(sqeu key val)} :: link eq rank
|: $:{p/(sqeu key val) q/(sqeu key val)} :: link eq rank
^- (sqeu key val)
?> =(r.p r.q)
?: (cmp k.p k.q)
@ -48,7 +50,7 @@
[r=+(r.q) k=k.q n=n.q c=[i=p t=c.q]]
::
++ sink :: skew link
|= {p/(sqeu key val) q/(sqeu key val) r/(sqeu key val)}
|: $:{p/(sqeu key val) q/(sqeu key val) r/(sqeu key val)}
^- (sqeu key val)
?: &((cmp k.q k.p) (cmp k.q k.r))
[r=+(r.q) k=k.q n=n.q c=[i=p t=[i=r t=c.q]]]
@ -57,7 +59,7 @@
[r=+(r.q) k=k.p n=n.p c=[i=q t=[i=r t=~]]]
::
++ sert :: internal ins op
|= {p/(sqeu key val) q/(broq key val)}
|: $:{{p/(sqeu key val) q/(broq key val)}}
^- (broq key val)
?~ q [p ~]
?> (lte r.p r.i.q)
@ -66,12 +68,12 @@
$(p (link p i.q), q t.q)
::
++ uniq :: remove init dup
|= q/(broq key val)
|: $:{q/(broq key val)}
?~ q ~
(sert i.q t.q)
::
++ meek :: unique meld
|= {p/(broq key val) q/(broq key val)}
|: $:{p/(broq key val) q/(broq key val)}
^- (broq key val)
?~ p q
?~ q p
@ -82,7 +84,7 @@
(sert (link i.p i.q) $(p t.p, q t.q))
::
++ mini :: getmin
|= q/(broq key val)
|: $:{q/(broq key val)}
^- p/{(sqeu key val) (broq key val)}
?~ q ~|(%fatal-mini-empty !!)
?~ t.q [i=i.q t=~]
@ -92,7 +94,7 @@
[l [i.q r]]
::
++ spit :: split
|= {p/(broq key val) q/(list {k/key n/val}) r/(broq key val)}
|: $:{p/(broq key val) q/(list {k/key n/val}) r/(broq key val)}
^- {t/(broq key val) x/(list {k/key n/val})}
?~ r
[t=p x=q]
@ -100,9 +102,10 @@
$(q [[k=k.i.r n=n.i.r] q], r t.r)
$(p [i.r p], r t.r)
--
|_ a/(broq key val) :: public interface
=+ $:{a/(broq key val)}
|% :: public interface
++ put :: insert element
|= {k/key n/val}
|: $:{k/key n/val}
^+ a
?~ a [i=[r=0 k=k n=n c=~] t=~]
?~ t.a [i=[r=0 k=k n=n c=~] t=a]
@ -120,9 +123,9 @@
(gas x)
::
++ gas
|= b/(list {k/key n/val})
|: $:{b/(list {k/key n/val})}
^+ a
(roll b |=({{k/key n/val} q/_a} (put(a q) k n)))
(roll b |:($:{{k/key n/val} q/_a} (put(a q) k n)))
::
++ tap
^- (list {k/key n/val})
@ -137,7 +140,7 @@
?.((cmp k.i.a p.m) m [k n]:i.a)
::
++ uni :: merge
|= q/(broq key val)
|: $:{q/(broq key val)}
^+ a
(meek (uniq a) (uniq q))
--

View File

@ -614,13 +614,15 @@
:: in `subs`.
::
++ duct-lift
|* send/_|=({duct *} ..duct-lift)
|= {a/(set duct) arg/_+<+.send} ^+ ..duct-lift
=+ all=~(tap by a)
|- ^+ ..duct-lift
?~ all ..duct-lift
=. +>.send ..duct-lift
$(all t.all, duct-lift (send i.all arg))
=+ send=|=({duct *} ..duct-lift)
|% +- $
|: $:{a/(set duct) arg/_+<+.send} ^+ ..duct-lift
=+ all=~(tap by a)
|- ^+ ..duct-lift
?~ all ..duct-lift
=. +>.send ..duct-lift
$(all t.all, duct-lift (send i.all arg))
--
::
++ blub-all (duct-lift |=({a/duct $~} (blub a))) :: lifted ++blub
++ blab-all (duct-lift blab) :: lifted ++blab
@ -1707,7 +1709,7 @@
(silt lat)
::
++ mabe :: maybe fire function
|= {rov/rove fun/$-(@da _.)}
|: $:{rov/rove fun/$-(@da _.)}
^+ +>.$
%+ fall
%+ bind

View File

@ -1,7 +1,6 @@
:: :: %eyre, http servant
!? 164
::::
!:
|= pit/vase
=, eyre
=, wired
@ -37,8 +36,8 @@
== == == ::
++ sign :: in result $<-
$? $: $a :: by %ames
$% {$woot p/ship q/coop} :: acknowledgment
{$went ship cape:ames} :: XX ignore
$% {$woot p/ship q/coop} :: acknowledgment
{$went ship cape:ames} :: XX ignore
== == ::
$: $b :: by %behn
$% {$wake $~} :: timer activate
@ -922,7 +921,7 @@
::
++ norm-beak |=(bek/beak ?+(r.bek bek {$ud $0} bek(r da+now)))
++ emule
|= a/_|?(..emule) ^+ ..emule
|: a=|?(..emule) ^+ ..emule
?: [unsafe=|]
(a)
=+ mul=(mule a)

View File

@ -29,7 +29,6 @@
:: it's important to keep %zuse minimal. models and
:: engines not used outside a vane should stay inside
:: that vane.
!:
~% %zuse +> ~
=>
:: :: ::
@ -3325,7 +3324,7 @@
^- (unit (list _[(wonk $:fel) (need $:wit)]))
%- zl
%+ turn ~(tap by a)
|= {a/cord b/_(need *wit)}
|: $:{a/cord b/_(need $:wit)}
=+ nit=(rush a fel)
?~ nit ~
(some [u.nit b])