Pass through mean

This commit is contained in:
Anton Dyudin 2015-04-07 13:31:09 -07:00
parent 9f7dd4a9ff
commit 970ac7bdb0
5 changed files with 158 additions and 9 deletions

View File

@ -468,7 +468,10 @@
=. our ?~(hov our u.hov) :: XX
?- &2.sih
%crud +>.$(mow [[hen %slip %d %flog +.sih] mow])
%dumb (emule |.(~|(%gall-stub !!)))
%dumb
=. +> ?+(tee +> [%of ^] pop-duct:(ire-ix p.tee))
(emule |.(~|(gall-dumb/tee !!)))
::
%went +>.$
%thou
?> ?=([%ay ^] tee)
@ -1102,13 +1105,11 @@
%mean
?~ p.b :: XX actually a yawn-told-full
(get-even %mean [[(slav %p p.a) q.a] r.a] p.b)
=^ ned med ~(get to med)
(mean-json:abet(hen ned) 500 p.b)
(mean-json:pop-duct 500 p.b)
::
%nice
?: =(~ med) ~& resp-lost/ire ..ix
=^ ned med ~(get to med)
(nice-json:abet(hen ned))
(nice-json:pop-duct)
==
::
++ get-even
@ -1138,6 +1139,7 @@
|= a=[p=hasp wire]
(pass-note(hen `~) [%of ire (gsig a)] [%g %took [- + ~]:p.a him])
::
++ pop-duct =^(ned med ~(get to med) abet(hen ned))
++ poll
|= a=@u ^+ ..ix
?: =(a p.eve)

142
main/lib/console/core.hook Normal file
View File

@ -0,0 +1,142 @@
::
:::: /hook/core/console/lib
::
:: This file is in the public domain.
::
/? 310
/- *console
!:
::::
::
|%
++ cs :: shared-state engine
|_ console-share
++ abet +<
++ apply
|= ted=console-edit
^+ +>
?- -.ted
%del +>.$(buf (weld (scag p.ted buf) (slag +(p.ted) buf)))
%ins +>.$(buf (weld (scag p.ted buf) `_buf`[q.ted (slag p.ted buf)]))
%mor |- ^+ +>.^$
?~ p.ted
+>.^$
$(p.ted t.p.ted, +>.^$ ^$(ted i.p.ted))
%nop +>.$
%set +>.$(buf p.ted)
==
::
::::
:: ++transmute: symmetric operational transformation.
::
:: for any console state +>, obeys
::
:: =+ [x=(transmute a b) y=(transmute b a)]
:: .= (apply:(apply b) x)
:: (apply:(apply a) y)
::
++ transmute :: dex as after sin
|= [sin=console-edit dex=console-edit]
^- console-edit
?: ?=(%mor -.sin)
|- ^- console-edit
?~ p.sin dex
$(p.sin t.p.sin, dex ^$(sin i.p.sin))
::
?: ?=(%mor -.dex)
:- %mor
|- ^- (list console-edit)
?~ p.dex ~
[^$(dex i.p.dex) $(p.dex t.p.dex)]
::
?: |(?=(%nop -.sin) ?=(%nop -.dex)) dex
?: ?=(%set -.sin) [%nop ~]
?: ?=(%set -.dex) dex
::
?- -.sin
%del
?- -.dex
%del ?: =(p.sin p.dex) [%nop ~]
?:((lth p.sin p.dex) dex(p (dec p.dex)) dex)
%ins ?:((lte p.sin p.dex) dex(p (dec p.dex)) dex)
==
::
%ins
?- -.dex
%del ?:((lte p.sin p.dex) dex(p +(p.dex)) dex)
%ins ?: =(p.sin p.dex)
?:((gth q.sin q.dex) dex dex(p +(p.dex)))
?:((lte p.sin p.dex) dex(p +(p.dex)) dex)
==
==
::
++ commit :: local change
|= ted=console-edit
^- console-share
abet:(apply(own.ven +(own.ven), leg [ted leg]) ted)
::
::::
:: ++inverse: inverse of change in context.
::
:: for any console state +>, obeys
::
:: =(+> (apply:(apply a) (inverse a)))
::
++ inverse :: relative inverse
|= ted=console-edit
^- console-edit
=. ted ?.(?=([%mor * ~] ted) ted i.p.ted)
?- -.ted
%del [%ins p.ted (snag p.ted buf)]
%ins [%del p.ted]
%mor :- %mor
%- flop
|- ^- (list console-edit)
?~ p.ted ~
:- ^$(ted i.p.ted)
$(p.ted t.p.ted, +>.^$ (apply i.p.ted))
%nop [%nop ~]
%set [%set buf]
==
::
++ receive :: naturalize event
|= console-change
^- [console-edit console-share]
?> &(=(his.ler his.ven) (lte own.ler own.ven))
?> &(=(his.ler his.ven) (lte own.ler own.ven))
?> |(!=(own.ler own.ven) =(haw (sham buf)))
=. leg (scag (sub own.ven own.ler) leg)
:: ~? !=(own.ler own.ven) [%miss-leg leg]
=+ dat=(transmute [%mor leg] ted)
:: ~? !=(~ leg) [%transmute from/ted to/dat ~]
[dat abet:(apply(his.ven +(his.ven)) dat)]
::
++ remit :: conditional accept
|= [cal=console-change ask=$+((list ,@c) ?)]
^- [(unit console-change) console-share]
=+ old=buf
=^ dat +>+<.$ (receive cal)
?: (ask buf)
[~ +>+<.$]
=^ lic +>+<.$ (transmit (inverse(buf old) dat))
[`lic +>+<.$]
::
++ transmit :: outgoing change
|= ted=console-edit
^- [console-change console-share]
[[[his.ven own.ven] (sham buf) ted] (commit ted)]
::
++ transceive :: receive and invert
|= console-change
^- [console-edit console-share]
=+ old=buf
=^ dat +>+<.$ (receive +<.$)
[(inverse(buf old) dat) +>+<.$]
::
++ transpose :: adjust position
|= pos=@ud
=+ dat=(transmute [%mor leg] [%ins pos `@c`0])
?> ?=(%ins -.dat)
p.dat
--
--

3
main/lib/shu/core.hook Normal file
View File

@ -0,0 +1,3 @@
:: Alias
/+ sh-utils
.

View File

@ -103,6 +103,8 @@ window.urb.poll = function(params) {
return document.location.reload() // XX check autoreload
case "rush":
case "mean":
if(res.data.type) == "mean"
err = res.data.data
var fn = $this.gsig(res.data.from)
if($this.cabs[fn])
$this.cabs[fn].call(this,err,

View File

@ -37,10 +37,10 @@
$% [%twitter p=@t] :: twitter
== ::
++ posture :: security posture
$? %black :: channel
%white :: village
%green :: journal
%brown :: mailbox
$? %black :: public
%white :: private
%green :: readonly
%brown :: writeonly
== ::
++ presence ?(%gone %hear %talk) :: status type
++ register (pair atlas (map partner atlas)) :: ping me, ping srcs