mirror of
https://github.com/ilyakooo0/urbit.git
synced 2025-01-05 22:03:50 +03:00
Merge branch 'master' of https://github.com/urbit/urbit
This commit is contained in:
commit
aac3f66774
@ -298,9 +298,17 @@
|
|||||||
?: =(~ mog) luv
|
?: =(~ mog) luv
|
||||||
?+ -.luv luv
|
?+ -.luv luv
|
||||||
%mid
|
%mid
|
||||||
=+ str=(trip q.q.luv)
|
?. =('<html' (end 3 5 q.q.luv)) luv
|
||||||
=+ scr=|-(^-(tape ?~(mog ~ (xmlt & i.mog $(mog t.mog)))))
|
=+ scr=(roll mog |=([a=manx b=tape] (xmlt & a b)))
|
||||||
=+ rep=(need (repg "<head data-scr=\"true\">" str (weld "<head data-scr=\"true\">" scr)))
|
=+ ^= hed
|
||||||
|
|- ;~ pose
|
||||||
|
(cook trip (jest '<head>'))
|
||||||
|
;~(plug prn (knee *tape ..$))
|
||||||
|
(easy ~)
|
||||||
|
==
|
||||||
|
=+ hop=(need q:(hed *hair (trip q.q.luv)))
|
||||||
|
?~ q.q.hop luv
|
||||||
|
=+ rep=:(welp p.hop scr q.q.hop)
|
||||||
[%mid p.luv (tact rep)]
|
[%mid p.luv (tact rep)]
|
||||||
==
|
==
|
||||||
++ lofe :: variables in head
|
++ lofe :: variables in head
|
||||||
|
136
arvo/ford.hoon
136
arvo/ford.hoon
@ -19,30 +19,30 @@
|
|||||||
== ::
|
== ::
|
||||||
++ hood :: assembly plan
|
++ hood :: assembly plan
|
||||||
$: zus=@ud :: zuse kelvin
|
$: zus=@ud :: zuse kelvin
|
||||||
sur=(list hook) :: structures
|
sur=(list hoot) :: structures
|
||||||
lib=(list hoof) :: libraries
|
lib=(list hoof) :: libraries
|
||||||
fan=(list horn) :: resources
|
fan=(list horn) :: resources
|
||||||
src=(list hoop) :: program
|
src=(list hoop) :: program
|
||||||
== ::
|
== ::
|
||||||
++ hoof (pair term (unit (pair case ship))) :: resource reference
|
++ hoof (pair term (unit (pair case ship))) :: resource reference
|
||||||
++ hook (pair bean hoof) :: structure gate/core
|
++ hoot (pair bean hoof) :: structure gate/core
|
||||||
++ hoop :: source in hood
|
++ hoop :: source in hood
|
||||||
$% [%& p=twig] :: direct twig
|
$% [%& p=twig] :: direct twig
|
||||||
[%| p=beam] :: resource location
|
[%| p=beam] :: resource location
|
||||||
== ::
|
== ::
|
||||||
++ horn :: resource tree
|
++ horn :: resource tree
|
||||||
$% [%and p=twig] :: /& twig by hand
|
$% [%ape p=twig] :: /& twig by hand
|
||||||
[%arg p=twig] :: /$ argument
|
[%arg p=twig] :: /$ argument
|
||||||
[%day p=horn] :: /| @dr map by @dr
|
[%day p=horn] :: /| list by @dr
|
||||||
[%dub p=term q=horn] :: /= apply face
|
[%dub p=term q=horn] :: /= apply face
|
||||||
[%fan p=(list horn)] :: /: list
|
[%fan p=(list horn)] :: /. list
|
||||||
[%for p=path q=horn] :: /, descend
|
[%for p=path q=horn] :: /, descend
|
||||||
[%hub p=horn] :: /@ map by @ud
|
[%hub p=horn] :: /@ list by @ud
|
||||||
[%man p=(map term horn)] :: /* map by hand
|
[%man p=(map span horn)] :: /* hetero map
|
||||||
[%nap p=horn] :: /% map by @tas
|
[%nap p=horn] :: /% homo map
|
||||||
[%now p=horn] :: /& map by @da
|
[%now p=horn] :: /& list by @da
|
||||||
[%saw p=twig q=horn] :: /; operate on
|
[%saw p=twig q=horn] :: /; operate on
|
||||||
[%see p=beam q=horn] :: /. relative to
|
[%see p=beam q=horn] :: /: relative to
|
||||||
[%sic p=tile q=horn] :: /^ cast
|
[%sic p=tile q=horn] :: /^ cast
|
||||||
[%toy p=mark] :: /mark/ static
|
[%toy p=mark] :: /mark/ static
|
||||||
== ::
|
== ::
|
||||||
@ -209,9 +209,13 @@
|
|||||||
|= kus=(unit silk)
|
|= kus=(unit silk)
|
||||||
^+ +>
|
^+ +>
|
||||||
?~ kus
|
?~ kus
|
||||||
|
=+ nym=(~(get by dym.bay) hen)
|
||||||
|
?~ nym :: XX should never
|
||||||
|
~& [%ford-mystery hen]
|
||||||
|
+>.$
|
||||||
=+ num=(need (~(get by dym.bay) hen))
|
=+ num=(need (~(get by dym.bay) hen))
|
||||||
=+ tas=(need (~(get by q.tad.bay) num))
|
=+ tas=(need (~(get by q.tad.bay) u.nym))
|
||||||
amok:~(camo zo [num tas])
|
amok:~(camo zo [u.nym tas])
|
||||||
=+ num=p.tad.bay
|
=+ num=p.tad.bay
|
||||||
?> !(~(has by dym.bay) hen)
|
?> !(~(has by dym.bay) hen)
|
||||||
=: p.tad.bay +(p.tad.bay)
|
=: p.tad.bay +(p.tad.bay)
|
||||||
@ -409,7 +413,7 @@
|
|||||||
++ fang :: protocol door
|
++ fang :: protocol door
|
||||||
|= [cof=cafe for=mark bek=beak]
|
|= [cof=cafe for=mark bek=beak]
|
||||||
^- (bolt vase)
|
^- (bolt vase)
|
||||||
=+ pax=/door/[for]/mac
|
=+ pax=/door/[for]/mar
|
||||||
=+ ^= bem ^- beam
|
=+ ^= bem ^- beam
|
||||||
:_ pax
|
:_ pax
|
||||||
?: =(p.bek our) bek
|
?: =(p.bek our) bek
|
||||||
@ -443,7 +447,7 @@
|
|||||||
==
|
==
|
||||||
::
|
::
|
||||||
;~ pose
|
;~ pose
|
||||||
(ifix [;~(plug fas hep gap) gap] (most ;~(plug com gaw) hook))
|
(ifix [;~(plug fas hep gap) gap] (most ;~(plug com gaw) hoot))
|
||||||
(easy ~)
|
(easy ~)
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
@ -467,7 +471,7 @@
|
|||||||
==
|
==
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ hook
|
++ hoot
|
||||||
;~ pose
|
;~ pose
|
||||||
(stag %| ;~(pfix tar hoof))
|
(stag %| ;~(pfix tar hoof))
|
||||||
(stag %& hoof)
|
(stag %& hoof)
|
||||||
@ -488,18 +492,19 @@
|
|||||||
;~ pfix fas
|
;~ pfix fas
|
||||||
;~ pose
|
;~ pose
|
||||||
(stag %toy ;~(sfix sym fas))
|
(stag %toy ;~(sfix sym fas))
|
||||||
(stag %and ;~(pfix and:sign and:read))
|
(stag %ape ;~(pfix sig ape:read))
|
||||||
(stag %arg ;~(pfix arg:sign and:read))
|
(stag %arg ;~(pfix buc ape:read))
|
||||||
(stag %day ;~(pfix day:sign day:read))
|
(stag %day ;~(pfix bar day:read))
|
||||||
(stag %dub ;~(pfix dub:sign dub:read))
|
(stag %dub ;~(pfix tis dub:read))
|
||||||
(stag %fan ;~(pfix fan:sign fan:read))
|
(stag %fan ;~(pfix dot fan:read))
|
||||||
(stag %for ;~(pfix for:sign for:read))
|
(stag %for ;~(pfix com for:read))
|
||||||
(stag %hub ;~(pfix hub:sign day:read))
|
(stag %hub ;~(pfix pat day:read))
|
||||||
(stag %man ;~(pfix man:sign man:read))
|
(stag %man ;~(pfix tar man:read))
|
||||||
(stag %nap ;~(pfix nap:sign day:read))
|
(stag %nap ;~(pfix cen day:read))
|
||||||
(stag %now ;~(pfix now:sign day:read))
|
(stag %now ;~(pfix fas day:read))
|
||||||
(stag %see ;~(pfix see:sign see:read))
|
(stag %saw ;~(pfix sem saw:read))
|
||||||
(stag %sic ;~(pfix sic:sign sic:read))
|
(stag %see ;~(pfix col see:read))
|
||||||
|
(stag %sic ;~(pfix ket sic:read))
|
||||||
==
|
==
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
@ -509,7 +514,7 @@
|
|||||||
;~(pose wid tal)
|
;~(pose wid tal)
|
||||||
::
|
::
|
||||||
++ read
|
++ read
|
||||||
|% ++ and
|
|% ++ ape
|
||||||
%+ rail
|
%+ rail
|
||||||
(ifix [sel ser] (stag %cltr (most ace wide:vez)))
|
(ifix [sel ser] (stag %cltr (most ace wide:vez)))
|
||||||
;~(pfix gap tall:vez)
|
;~(pfix gap tall:vez)
|
||||||
@ -546,30 +551,20 @@
|
|||||||
::
|
::
|
||||||
++ see
|
++ see
|
||||||
%+ rail
|
%+ rail
|
||||||
;~(plug (ifix [sel ser] have) apex(tol |))
|
;~(plug ;~(sfix have col) apex(tol |))
|
||||||
;~(pfix gap ;~(plug have ;~(pfix gap apex)))
|
;~(pfix gap ;~(plug have ;~(pfix gap apex)))
|
||||||
|
::
|
||||||
|
++ saw
|
||||||
|
%+ rail
|
||||||
|
;~(plug ;~(sfix wide:vez sem) apex(tol |))
|
||||||
|
;~(pfix gap ;~(plug tall:vez ;~(pfix gap apex)))
|
||||||
::
|
::
|
||||||
++ sic
|
++ sic
|
||||||
%+ rail
|
%+ rail
|
||||||
;~(plug (ifix [sel ser] toil:vez) apex(tol |))
|
;~(plug ;~(sfix toil:vez ket) apex(tol |))
|
||||||
;~(pfix gap ;~(plug howl:vez ;~(pfix gap apex)))
|
;~(pfix gap ;~(plug howl:vez ;~(pfix gap apex)))
|
||||||
--
|
--
|
||||||
::
|
::
|
||||||
++ sign
|
|
||||||
|% ++ and ;~(pose pam (jest %and))
|
|
||||||
++ arg ;~(pose buc (jest %arg))
|
|
||||||
++ day ;~(pose bar (jest %day))
|
|
||||||
++ dub ;~(pose tis (jest %dub))
|
|
||||||
++ fan ;~(pose col (jest %fan))
|
|
||||||
++ for ;~(pose com (jest %for))
|
|
||||||
++ hub ;~(pose pat (jest %hub))
|
|
||||||
++ man ;~(pose tar (jest %man))
|
|
||||||
++ nap ;~(pose cen (jest %nap))
|
|
||||||
++ now ;~(pose fas (jest %now))
|
|
||||||
++ saw ;~(pose sem (jest %saw))
|
|
||||||
++ see ;~(pose dot (jest %see))
|
|
||||||
++ sic ;~(pose ket (jest %sic))
|
|
||||||
--
|
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
::
|
::
|
||||||
@ -963,40 +958,62 @@
|
|||||||
|= [cof=cafe sel=_..body]
|
|= [cof=cafe sel=_..body]
|
||||||
^$(cof cof, src t.src, ..body sel)
|
^$(cof cof, src t.src, ..body sel)
|
||||||
::
|
::
|
||||||
++ chai :: atomic map
|
++ chad :: atomic list
|
||||||
|= [cof=cafe bax=vase doe=term hon=horn]
|
|= [cof=cafe bax=vase doe=term hon=horn]
|
||||||
^- (bolt vase)
|
^- (bolt vase)
|
||||||
%+ cope ((lash (slat doe)) cof how)
|
%+ cope ((lash (slat doe)) cof how)
|
||||||
|= [cof=cafe yep=(map ,@ span)]
|
|= [cof=cafe yep=(map ,@ span)]
|
||||||
|
=+ ^= poy ^- (list (pair ,@ span))
|
||||||
|
%+ sort (~(tap by yep) ~)
|
||||||
|
|=([a=[@ *] b=[@ *]] (lth -.a -.b))
|
||||||
|
%+ cope
|
||||||
|
|- ^- (bolt (list (pair ,@ vase)))
|
||||||
|
?~ poy (fine cof ~)
|
||||||
|
%+ cope $(poy t.poy)
|
||||||
|
|= [cof=cafe nex=(list (pair ,@ vase))]
|
||||||
|
%+ cope (chap(s.how [q.i.poy s.how]) cof bax hon)
|
||||||
|
|= [cof=cafe elt=vase]
|
||||||
|
(fine cof [[p.i.poy elt] nex])
|
||||||
|
|= [cof=cafe yal=(list (pair ,@ vase))]
|
||||||
|
%+ fine cof
|
||||||
|
|- ^- vase
|
||||||
|
?~ yal [[%cube 0 [%atom %n]] 0]
|
||||||
|
(slop (slop [[%atom doe] p.i.yal] q.i.yal) $(yal t.yal))
|
||||||
|
::
|
||||||
|
++ chai :: atomic map
|
||||||
|
|= [cof=cafe bax=vase hon=horn]
|
||||||
|
^- (bolt vase)
|
||||||
|
%+ cope (lend cof how)
|
||||||
|
|= [cof=cafe arc=arch]
|
||||||
%+ cope
|
%+ cope
|
||||||
|- ^- (bolt (map ,@ vase))
|
|- ^- (bolt (map ,@ vase))
|
||||||
?~ yep (fine cof ~)
|
?~ r.arc (fine cof ~)
|
||||||
%+ cope $(yep l.yep)
|
%+ cope $(r.arc l.r.arc)
|
||||||
|= [cof=cafe lef=(map ,@ vase)]
|
|= [cof=cafe lef=(map ,@ vase)]
|
||||||
%+ cope `(bolt (map ,@ vase))`^$(cof cof, yep r.yep)
|
%+ cope `(bolt (map ,@ vase))`^$(cof cof, r.arc r.r.arc)
|
||||||
|= [cof=cafe rig=(map ,@ vase)]
|
|= [cof=cafe rig=(map ,@ vase)]
|
||||||
%+ cope (chap(s.how [q.n.yep s.how]) cof bax hon)
|
%+ cope (chap(s.how [p.n.r.arc s.how]) cof bax hon)
|
||||||
|= [cof=cafe nod=vase]
|
|= [cof=cafe nod=vase]
|
||||||
(fine cof [[p.n.yep nod] lef rig])
|
(fine cof [[p.n.r.arc nod] lef rig])
|
||||||
|= [cof=cafe doy=(map ,@ vase)]
|
|= [cof=cafe doy=(map ,@ vase)]
|
||||||
%+ fine cof
|
%+ fine cof
|
||||||
|- ^- vase
|
|- ^- vase
|
||||||
?~ doy [[%cube 0 [%atom %n]] 0]
|
?~ doy [[%cube 0 [%atom %n]] 0]
|
||||||
%+ slop
|
%+ slop
|
||||||
(slop [[%atom doe] p.n.doy] q.n.doy)
|
(slop [[%atom %a] p.n.doy] q.n.doy)
|
||||||
(slop $(doy l.doy) $(doy r.doy))
|
(slop $(doy l.doy) $(doy r.doy))
|
||||||
::
|
::
|
||||||
++ chap :: produce resources
|
++ chap :: produce resources
|
||||||
|= [cof=cafe bax=vase hon=horn]
|
|= [cof=cafe bax=vase hon=horn]
|
||||||
^- (bolt vase)
|
^- (bolt vase)
|
||||||
?- -.hon
|
?- -.hon
|
||||||
%and (maim cof bax p.hon)
|
%ape (maim cof bax p.hon)
|
||||||
%arg
|
%arg
|
||||||
%+ cope (maim cof bax p.hon)
|
%+ cope (maim cof bax p.hon)
|
||||||
|= [cof=cafe gat=vase]
|
|= [cof=cafe gat=vase]
|
||||||
(maul cof gat !>([how arg]))
|
(maul cof gat !>([how arg]))
|
||||||
::
|
::
|
||||||
%day (chai cof bax %dr p.hon)
|
%day (chad cof bax %dr p.hon)
|
||||||
%dub
|
%dub
|
||||||
%+ cope $(hon q.hon)
|
%+ cope $(hon q.hon)
|
||||||
|= [cof=cafe vax=vase]
|
|= [cof=cafe vax=vase]
|
||||||
@ -1018,7 +1035,7 @@
|
|||||||
(slop i.tev $(tev t.tev))
|
(slop i.tev $(tev t.tev))
|
||||||
::
|
::
|
||||||
%for $(hon q.hon, s.how (weld (flop p.hon) s.how))
|
%for $(hon q.hon, s.how (weld (flop p.hon) s.how))
|
||||||
%hub (chai cof bax %ud p.hon)
|
%hub (chad cof bax %ud p.hon)
|
||||||
%man
|
%man
|
||||||
|- ^- (bolt vase)
|
|- ^- (bolt vase)
|
||||||
?~ p.hon (fine cof [[%cube 0 [%atom %n]] 0])
|
?~ p.hon (fine cof [[%cube 0 [%atom %n]] 0])
|
||||||
@ -1033,9 +1050,8 @@
|
|||||||
(slop [[%atom %tas] p.n.p.hon] vax)
|
(slop [[%atom %tas] p.n.p.hon] vax)
|
||||||
(slop lef rig)
|
(slop lef rig)
|
||||||
::
|
::
|
||||||
%now (chai cof bax %da p.hon)
|
%now (chad cof bax %da p.hon)
|
||||||
%nap (chai cof bax %tas p.hon)
|
%nap (chai cof bax p.hon)
|
||||||
::
|
|
||||||
%see $(hon q.hon, how p.hon)
|
%see $(hon q.hon, how p.hon)
|
||||||
%saw
|
%saw
|
||||||
%+ cope $(hon q.hon)
|
%+ cope $(hon q.hon)
|
||||||
@ -1051,13 +1067,13 @@
|
|||||||
|= [cof=cafe tug=vase]
|
|= [cof=cafe tug=vase]
|
||||||
?. (~(nest ut p.tug) | p.vax)
|
?. (~(nest ut p.tug) | p.vax)
|
||||||
(flaw cof [%leaf "type error: {<p.hon>} {<q.hon>}"]~)
|
(flaw cof [%leaf "type error: {<p.hon>} {<q.hon>}"]~)
|
||||||
(fine cof vax)
|
(fine cof [p.tug q.vax])
|
||||||
::
|
::
|
||||||
%toy (cope (make cof %bake p.hon how ~) feel)
|
%toy (cope (make cof %bake p.hon how ~) feel)
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ head :: consume structures
|
++ head :: consume structures
|
||||||
|= [cof=cafe bir=(list hook)]
|
|= [cof=cafe bir=(list hoot)]
|
||||||
|- ^- (bolt ,_..head)
|
|- ^- (bolt ,_..head)
|
||||||
?~ bir
|
?~ bir
|
||||||
(fine cof ..head)
|
(fine cof ..head)
|
||||||
|
@ -9889,7 +9889,7 @@
|
|||||||
%pass
|
%pass
|
||||||
~? &(!lac !=(%$ p.gum))
|
~? &(!lac !=(%$ p.gum))
|
||||||
:^ %pass [p.gum p.q.r.gum]
|
:^ %pass [p.gum p.q.r.gum]
|
||||||
[(,@tas -.q.gum) p.r.gum]
|
[(,@tas +>-.q.q.r.gum) p.r.gum]
|
||||||
q.gum
|
q.gum
|
||||||
[p.q.r.gum ~ [[p.gum p.r.gum] q.gum] q.q.r.gum]
|
[p.q.r.gum ~ [[p.gum p.r.gum] q.gum] q.q.r.gum]
|
||||||
::
|
::
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
!:
|
|
||||||
::::::::: Appbug: a simple application.
|
|
||||||
::
|
|
||||||
|_ [hid=hide vat=[%0 p=@ud]]
|
|
||||||
++ poke
|
|
||||||
|= [ost=bone *]
|
|
||||||
:_ +>(p.vat +(p.vat))
|
|
||||||
:~ [ost %give %nice ~]
|
|
||||||
==
|
|
||||||
::
|
|
||||||
++ peek
|
|
||||||
|= [you=ship pax=path]
|
|
||||||
:- %hymn
|
|
||||||
^- manx
|
|
||||||
;html
|
|
||||||
;head
|
|
||||||
;title: Appbug!
|
|
||||||
;script: appl = '{(trip app.hid)}'
|
|
||||||
==
|
|
||||||
;body
|
|
||||||
;p: Dude, a better answer is {<p.vat>}.
|
|
||||||
;button(onclick "bump()"): (Bump.)
|
|
||||||
;script
|
|
||||||
; var mess = 0;
|
|
||||||
;
|
|
||||||
; function bump() {
|
|
||||||
; xhr = new XMLHttpRequest();
|
|
||||||
; xhr.onload = function() { mess++; }
|
|
||||||
; xhr.open("PUT", "/tim/" + [user, port, mess].join("/"));
|
|
||||||
; xhr.setRequestHeader("content-type", "text/json");
|
|
||||||
; xhr.send(JSON.stringify({oryx: oryx, xyro: {ship: ship, appl: appl, data: {}}}));
|
|
||||||
; }
|
|
||||||
==
|
|
||||||
==
|
|
||||||
==
|
|
||||||
--
|
|
||||||
|
|
||||||
|
|
39
main/app/demo/core.hook
Normal file
39
main/app/demo/core.hook
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
!:
|
||||||
|
::::::::: Appbug: a simple application.
|
||||||
|
::
|
||||||
|
|_ [hid=hide vat=[%0 p=@ud]]
|
||||||
|
++ poke
|
||||||
|
|= [ost=bone *]
|
||||||
|
:_ +>(p.vat +(p.vat))
|
||||||
|
:~ [ost %give %nice ~]
|
||||||
|
==
|
||||||
|
::
|
||||||
|
++ peek
|
||||||
|
|= [you=ship pax=path]
|
||||||
|
:- %hymn
|
||||||
|
^- manx
|
||||||
|
;html
|
||||||
|
;head
|
||||||
|
;title: Demo!
|
||||||
|
;script: urb.appl = '{(trip app.hid)}'
|
||||||
|
==
|
||||||
|
;body
|
||||||
|
;p: State is {<p.vat>}.
|
||||||
|
;button(onclick "bump()"): (Bump.)
|
||||||
|
;script
|
||||||
|
; var mess = 0
|
||||||
|
;
|
||||||
|
; function bump() {
|
||||||
|
; xhr = new XMLHttpRequest()
|
||||||
|
; xhr.onload = function() { mess++}
|
||||||
|
; xhr.open("PUT", "/tim/" + [urb.user, urb.port, mess].join("/"))
|
||||||
|
; xhr.setRequestHeader("content-type", "text/json")
|
||||||
|
; xyro = {ship: urb.ship, appl: urb.appl, data: {}}
|
||||||
|
; xhr.send(JSON.stringify({oryx: urb.oryx, xyro: xyro}))
|
||||||
|
; }
|
||||||
|
==
|
||||||
|
==
|
||||||
|
==
|
||||||
|
--
|
||||||
|
|
||||||
|
|
@ -1,103 +0,0 @@
|
|||||||
!:
|
|
||||||
=> |%
|
|
||||||
++ axle
|
|
||||||
$% [%0 p=@ud]
|
|
||||||
==
|
|
||||||
++ gult
|
|
||||||
$% [%json p=json]
|
|
||||||
:: [%hymn p=manx]
|
|
||||||
==
|
|
||||||
++ gilt
|
|
||||||
$% :: [%json p=json]
|
|
||||||
[%hymn p=manx]
|
|
||||||
==
|
|
||||||
++ gift
|
|
||||||
$% [%rust gilt]
|
|
||||||
[%nice gult]
|
|
||||||
==
|
|
||||||
++ move ,[p=bone q=[%give p=gift]]
|
|
||||||
--
|
|
||||||
|_ [hid=hide vat=axle]
|
|
||||||
++ page
|
|
||||||
^- manx
|
|
||||||
;html
|
|
||||||
;head
|
|
||||||
;title: Foobug!
|
|
||||||
==
|
|
||||||
;body
|
|
||||||
;p: Word: {<p.vat>}.
|
|
||||||
;button(onclick "goof()"): Goof!
|
|
||||||
;script:'''
|
|
||||||
var c = 0;
|
|
||||||
var d = 1;
|
|
||||||
var x = 0;
|
|
||||||
|
|
||||||
function pickup() {
|
|
||||||
xhr = new XMLHttpRequest();
|
|
||||||
|
|
||||||
console.log("WTF???");
|
|
||||||
xhr.open("GET", "/zod/goe/foobug/"+port+"/frog/"+d);
|
|
||||||
xhr.onload = function() {
|
|
||||||
console.log("pickup");
|
|
||||||
console.log(this)
|
|
||||||
change(JSON.parse(this.responseText))
|
|
||||||
update();
|
|
||||||
d++;
|
|
||||||
pickup();
|
|
||||||
}
|
|
||||||
xhr.send();
|
|
||||||
}
|
|
||||||
|
|
||||||
function dude() {
|
|
||||||
xhr = new XMLHttpRequest();
|
|
||||||
|
|
||||||
xhr.open("POST", "/zod/pos/foobug/"+port+"/frog/goof");
|
|
||||||
xhr.setRequestHeader("content-type", "text/json")
|
|
||||||
xhr.onload = function() {
|
|
||||||
console.log("dude");
|
|
||||||
console.log(this)
|
|
||||||
change(JSON.parse(this.responseText))
|
|
||||||
update();
|
|
||||||
pickup();
|
|
||||||
}
|
|
||||||
xhr.send("{\"a\":1}")
|
|
||||||
}
|
|
||||||
dude();
|
|
||||||
|
|
||||||
function change(jon) {
|
|
||||||
x = jon.x;
|
|
||||||
}
|
|
||||||
|
|
||||||
function update() {
|
|
||||||
document.getElementsByTagName("p")[0].innerHTML = "WORD: " + x;
|
|
||||||
}
|
|
||||||
|
|
||||||
function goof() {
|
|
||||||
xhr = new XMLHttpRequest();
|
|
||||||
xhr.onload = function() {
|
|
||||||
console.log("hi");
|
|
||||||
console.log(arguments)
|
|
||||||
c++
|
|
||||||
}
|
|
||||||
xhr.open("POST",
|
|
||||||
"/zod/pom/foobug/"+port+"/"+c)
|
|
||||||
xhr.setRequestHeader("content-type", "text/json")
|
|
||||||
xhr.send("{\"a\":1}")
|
|
||||||
}
|
|
||||||
'''
|
|
||||||
==
|
|
||||||
==
|
|
||||||
::
|
|
||||||
++ peer
|
|
||||||
|= [ost=bone you=ship pax=path]
|
|
||||||
^- [(list move) _+>]
|
|
||||||
[[ost %give %rust %hymn page]~ +>]
|
|
||||||
::
|
|
||||||
++ poke-json
|
|
||||||
|= [ost=bone you=ship jon=json]
|
|
||||||
^- [(list move) _+>]
|
|
||||||
~& [%poke [%state p.vat] ost you jon]
|
|
||||||
:_ +>(p.vat +(p.vat))
|
|
||||||
:~ [ost %give %nice %json jon]
|
|
||||||
==
|
|
||||||
--
|
|
@ -1,45 +0,0 @@
|
|||||||
|
|
||||||
window.onload = function() {
|
|
||||||
var data = {}
|
|
||||||
|
|
||||||
change = function(_data) {
|
|
||||||
for(i in _data) {
|
|
||||||
data[i] = _data[i]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
update = function() {
|
|
||||||
for (var i in data) {
|
|
||||||
if ($('#'+i).length < 1) {
|
|
||||||
var e = document.createElement('tr')
|
|
||||||
e.id = i
|
|
||||||
$('#cont tbody').append(e)
|
|
||||||
}
|
|
||||||
$('#'+i).html("<td>~"+i+"</td><td>"+data[i]+"</td>")
|
|
||||||
}
|
|
||||||
$('#cont tbody').append([].sort.call($('#cont tr'), function (a, b) {
|
|
||||||
return parseInt(b.childNodes[1].innerText) -
|
|
||||||
parseInt(a.childNodes[1].innerText)
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
goof = function(e) {
|
|
||||||
d = $.map($(".sel"), function(el) {return el.id})
|
|
||||||
window.urb.send(d)
|
|
||||||
}
|
|
||||||
|
|
||||||
window.urb.send(null);
|
|
||||||
/*window.urb.subscribe("frog","goof",*/ function(err,res) {
|
|
||||||
if(err)
|
|
||||||
return console.log('cannot connect to frog/goof')
|
|
||||||
change(res.data)
|
|
||||||
update()
|
|
||||||
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
|
|
||||||
$('#cont').on('click', 'tr', function (e) {
|
|
||||||
if (!e.ctrlKey) { $('.sel').removeClass('sel') }
|
|
||||||
$(this).addClass('sel')
|
|
||||||
})
|
|
||||||
}
|
|
@ -1,116 +0,0 @@
|
|||||||
!:
|
|
||||||
=> |%
|
|
||||||
++ axle
|
|
||||||
$% [%0 p=(map ,@p ,@ud)]
|
|
||||||
==
|
|
||||||
++ gilt
|
|
||||||
$% [%json p=json]
|
|
||||||
[%hymn p=manx]
|
|
||||||
==
|
|
||||||
++ gift
|
|
||||||
$% [%rust gilt]
|
|
||||||
[%nice gilt]
|
|
||||||
==
|
|
||||||
++ move ,[p=bone q=[%give p=gift]]
|
|
||||||
++ phil
|
|
||||||
$% [%new ~]
|
|
||||||
[%add p=(list ,@p)]
|
|
||||||
==
|
|
||||||
--
|
|
||||||
|_ [hid=hide vat=axle]
|
|
||||||
++ incl
|
|
||||||
|= wal=wall
|
|
||||||
%+ turn wal
|
|
||||||
|= tape ;script(type "text/javascript", src +<);
|
|
||||||
::
|
|
||||||
++ root
|
|
||||||
/(scot %p our.hid)/main/(scot %da lat.hid)/app/[app.hid]
|
|
||||||
::
|
|
||||||
++ respond :: respond to message
|
|
||||||
|= ost=bone
|
|
||||||
`move`[ost %give %nice %json *json]
|
|
||||||
::
|
|
||||||
++ update :: update subscribers
|
|
||||||
^- (list move)
|
|
||||||
%+ turn
|
|
||||||
^- (list bone)
|
|
||||||
%+ ~(rep by sup.hid) *(list bone)
|
|
||||||
|= [p=[p=bone q=[ship path]] q=(list bone)] ^- (list bone)
|
|
||||||
?. =(/goof +.q.p) q
|
|
||||||
[p.p q]
|
|
||||||
send-vat
|
|
||||||
::
|
|
||||||
++ render
|
|
||||||
^- manx
|
|
||||||
;html
|
|
||||||
;head
|
|
||||||
;title: Foobug!
|
|
||||||
;style
|
|
||||||
; .sel {background: lightgray}
|
|
||||||
; #cont {border-collapse: collapse}
|
|
||||||
==
|
|
||||||
;* %- incl :~
|
|
||||||
"//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"
|
|
||||||
==
|
|
||||||
;script ;- (trip ;;(,@ .^(%cx (welp root /urb/js))))
|
|
||||||
==
|
|
||||||
;script ;- (trip ;;(,@ .^(%cx (welp root /app/js))))
|
|
||||||
==
|
|
||||||
==
|
|
||||||
;body
|
|
||||||
;p: Yo.
|
|
||||||
;table#cont:tbody;
|
|
||||||
;p: Select a ship
|
|
||||||
;button(onclick "goof()"): Give 5 points
|
|
||||||
==
|
|
||||||
==
|
|
||||||
::
|
|
||||||
++ peer
|
|
||||||
|= [ost=bone you=ship pax=path]
|
|
||||||
^- [(list move) _+>]
|
|
||||||
:_ +>
|
|
||||||
?: =(/ pax)
|
|
||||||
[ost %give %rust %hymn render]~
|
|
||||||
[(send-vat ost) ~]
|
|
||||||
::
|
|
||||||
++ poke-phil
|
|
||||||
|= [ost=bone you=ship pil=phil]
|
|
||||||
=. p.vat
|
|
||||||
?- -.pil
|
|
||||||
%new (~(put by p.vat) you (fall (~(get by p.vat) you) _@ud))
|
|
||||||
%add %- ~(urn by p.vat)
|
|
||||||
|= [u=@p n=@ud]
|
|
||||||
?. (lien p.pil |=(a=@p =(a u)))
|
|
||||||
n
|
|
||||||
(add 5 n)
|
|
||||||
==
|
|
||||||
[[(respond ost) update] +>.$]
|
|
||||||
::
|
|
||||||
++ poke-json
|
|
||||||
|= [ost=bone you=ship jon=json]
|
|
||||||
~& [%poke-json jon]
|
|
||||||
%^ poke-phil ost you
|
|
||||||
^- phil
|
|
||||||
?+ -.jon !!
|
|
||||||
%o [%new ~]
|
|
||||||
%a :- %add
|
|
||||||
%+ turn p.jon
|
|
||||||
|= a=json
|
|
||||||
?> ?=([%s *] a)
|
|
||||||
(slav %p (cat 3 '~' p.a))
|
|
||||||
==
|
|
||||||
::
|
|
||||||
++ send-vat
|
|
||||||
|= ost=bone
|
|
||||||
=+ luz=(~(tap by p.vat) ~)
|
|
||||||
^- move
|
|
||||||
:* ost %give %rust %json %o
|
|
||||||
^- (map ,@t jval)
|
|
||||||
%- mo
|
|
||||||
%+ turn luz
|
|
||||||
|= [a=@p b=@ud]
|
|
||||||
:- (rsh 3 1 (scot %p a))
|
|
||||||
:- %n
|
|
||||||
(rsh 3 2 (scot %ui b))
|
|
||||||
==
|
|
||||||
--
|
|
@ -1,111 +0,0 @@
|
|||||||
window.urb = {
|
|
||||||
ship: ship,
|
|
||||||
port: port,
|
|
||||||
auto: auto,
|
|
||||||
oryx: oryx,
|
|
||||||
user: user,
|
|
||||||
appn: appn,
|
|
||||||
seqn: 0,
|
|
||||||
seqp: 1,
|
|
||||||
dely: 0,
|
|
||||||
|
|
||||||
req: function(method,url,data,json,cb) {
|
|
||||||
var xhr = new XMLHttpRequest()
|
|
||||||
xhr.open(method.toUpperCase(), url)
|
|
||||||
if(json)
|
|
||||||
xhr.setRequestHeader("content-type", "text/json")
|
|
||||||
if(data)
|
|
||||||
xhr.send(JSON.stringify(data))
|
|
||||||
else
|
|
||||||
xhr.send()
|
|
||||||
if(cb) {
|
|
||||||
xhr.onload = function() {
|
|
||||||
cb(null,{
|
|
||||||
"status":this.status,
|
|
||||||
"data":JSON.parse(this.responseText)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
xhr.onerror = function() {
|
|
||||||
cb({
|
|
||||||
"status":this.status,
|
|
||||||
"data":this.responseText
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
subscribe: function(stream,path,cb) {
|
|
||||||
if(!cb)
|
|
||||||
throw new Error("You must supply a callback to urb.subscribe.")
|
|
||||||
|
|
||||||
var method, perm, url, $this
|
|
||||||
|
|
||||||
method = "post"
|
|
||||||
perm = "pis"
|
|
||||||
url = [this.ship,perm,this.user,this.appn,this.port]
|
|
||||||
if(stream) {
|
|
||||||
url.push(stream)
|
|
||||||
if(path)
|
|
||||||
url.push(path)
|
|
||||||
}
|
|
||||||
url = "/"+url.join("/")
|
|
||||||
|
|
||||||
|
|
||||||
$this = this
|
|
||||||
this.req(method,url,{},true,function(err,data) {
|
|
||||||
cb.apply(this,arguments)
|
|
||||||
if(!err) { $this.poll(stream,cb); }
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
send: function(data,cb) {
|
|
||||||
if(!data) { data = {}; }
|
|
||||||
if(!cb) { cb = function() {}; }
|
|
||||||
|
|
||||||
var method, perm, url, $this
|
|
||||||
|
|
||||||
method = "post"
|
|
||||||
perm = "pim"
|
|
||||||
url = [this.ship,perm,this.user,this.appn,this.port,this.seqn]
|
|
||||||
url = "/"+url.join("/")
|
|
||||||
|
|
||||||
this.seqn++
|
|
||||||
|
|
||||||
$this = this
|
|
||||||
this.req(method,url,data,true,function(err,data) {
|
|
||||||
if(err) { $this.seqn--; }
|
|
||||||
cb.apply(this,arguments)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
poll: function(stream,cb) {
|
|
||||||
if(!stream)
|
|
||||||
throw new Error("You must supply a stream to urb.poll.")
|
|
||||||
if(!cb)
|
|
||||||
throw new Error("You must supply a callback to urb.poll.")
|
|
||||||
|
|
||||||
var method, perm, url, $this
|
|
||||||
|
|
||||||
method = "get"
|
|
||||||
perm = "gie"
|
|
||||||
if(!stream) { return false; }
|
|
||||||
url = [this.ship,perm,this.user,this.appn,this.port,stream,this.seqp]
|
|
||||||
url = "/"+url.join("/")
|
|
||||||
|
|
||||||
$this = this
|
|
||||||
this.req(method,url,null,false,function(err,data) {
|
|
||||||
if(cb.apply(this,arguments) === false) { return; }
|
|
||||||
|
|
||||||
if(err)
|
|
||||||
$this.dely += 1000
|
|
||||||
else {
|
|
||||||
$this.dely = 0
|
|
||||||
$this.seqp++
|
|
||||||
}
|
|
||||||
|
|
||||||
setTimeout(function() {
|
|
||||||
$this.poll(stream,cb)
|
|
||||||
},$this.dely)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
!:
|
|
||||||
:: Read ::
|
|
||||||
|_ [hid=hide vat=tape]
|
|
||||||
++ peer
|
|
||||||
|= [ost=bone ship pax=path]
|
|
||||||
~& pax
|
|
||||||
?~ pax
|
|
||||||
$(pax ~[(rsh 3 1 (scot %p our.hid))])
|
|
||||||
?> ?=([cord ~] pax)
|
|
||||||
:_ +>.$
|
|
||||||
:~ [ost %pass /ret %g %show [(slav %p (cat 3 '~' i.pax)) %written] our.hid /]
|
|
||||||
:: :^ ost %pass /heyya
|
|
||||||
:: :^ %g %mess [(slav %p (cat 3 '~' i.pax)) %written]
|
|
||||||
:: :+ our.hid %json !>(`json`[%s %hola])
|
|
||||||
:: :^ ost %pass /heyya
|
|
||||||
:: :^ %g %mess [(slav %p (cat 3 '~' i.pax)) %written]
|
|
||||||
:: :+ our.hid %json !>(`json`[%s %buenos-dias])
|
|
||||||
:: :^ ost %pass /heyya
|
|
||||||
:: :^ %g %mess [(slav %p (cat 3 '~' i.pax)) %written]
|
|
||||||
:: :+ our.hid %json !>(`json`[%s %buenas-tardes])
|
|
||||||
:: :^ ost %pass /heyya
|
|
||||||
:: :^ %g %mess [(slav %p (cat 3 '~' i.pax)) %written]
|
|
||||||
:: :+ our.hid %json !>(`json`[%s %buenas-tardes])
|
|
||||||
==
|
|
||||||
++ pour
|
|
||||||
|= [pax=path sin=*]
|
|
||||||
:_ +>
|
|
||||||
?: =(/ret pax)
|
|
||||||
=+ sin=;;(,[%g p=@tas q=*] sin)
|
|
||||||
?: ?=(%nice p.sin)
|
|
||||||
~& %pour-nice ~
|
|
||||||
?: ?=(%mean p.sin)
|
|
||||||
~& %pour-mean ~
|
|
||||||
=+ sin=;;(,[%g p=@tas q=mark r=*] sin)
|
|
||||||
~& [%pour-ret p.sin q.sin]
|
|
||||||
=+ gif=;;(,[?(%rust %rush) %hymn manx] +.sin)
|
|
||||||
%+ turn (~(tap by sup.hid))
|
|
||||||
|= [ost=bone you=ship pax=path]
|
|
||||||
[ost give/gif]
|
|
||||||
?: =(/heyya pax)
|
|
||||||
~& [%pour-acked sin]
|
|
||||||
~
|
|
||||||
~& %pour-bad ~
|
|
||||||
--
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
|||||||
!:
|
|
||||||
=> |%
|
|
||||||
++ gift
|
|
||||||
$% [%mean p=ares]
|
|
||||||
[%nice ~]
|
|
||||||
[%rust %hymn manx]
|
|
||||||
==
|
|
||||||
++ move ,[p=bone q=(mold note gift)]
|
|
||||||
++ note ,~
|
|
||||||
--
|
|
||||||
:: Write ::
|
|
||||||
|_ [hid=hide vat=tape]
|
|
||||||
++ root
|
|
||||||
[(crip <our.hid>) %main (crip <lat.hid>) ~]
|
|
||||||
::
|
|
||||||
++ page
|
|
||||||
:- %hymn
|
|
||||||
;html
|
|
||||||
;head
|
|
||||||
;title: Writer
|
|
||||||
;script:"{(trip (,@ (need (file (welp root /lib/urb/js)))))}"
|
|
||||||
==
|
|
||||||
;body
|
|
||||||
;p: Write things!
|
|
||||||
;+ =+ js="urb.send(\{appl:{<`@t`app.hid>}, data:texx.value})"
|
|
||||||
;textarea(id "texx", onchange js):"{vat}"
|
|
||||||
==
|
|
||||||
==
|
|
||||||
++ peer
|
|
||||||
|= [ost=bone you=ship pax=path]
|
|
||||||
:_ +>.$ :_ ~
|
|
||||||
:^ ost %give %rust
|
|
||||||
page
|
|
||||||
:: ^- [(list move) _+>]
|
|
||||||
:: :_ +>.$ :_ ~
|
|
||||||
:: [ost %give %rust page]
|
|
||||||
++ poke-json
|
|
||||||
|= [ost=bone you=ship jon=json]
|
|
||||||
^- [(list move) _+>]
|
|
||||||
=. vat (need (sa:jo jon))
|
|
||||||
~& [%poke-vat vat]
|
|
||||||
:_ +>.$
|
|
||||||
:* [ost %give %mean ~ %alan-kay ~[leaf/"is a failure"]]
|
|
||||||
~
|
|
||||||
:: %+ turn (~(tap by sup.hid))
|
|
||||||
:: |= [ost=bone you=ship pax=path]
|
|
||||||
:: [ost %give %rust page]
|
|
||||||
==
|
|
||||||
--
|
|
5
main/lib/example/core.hook
Normal file
5
main/lib/example/core.hook
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|%
|
||||||
|
++ fib |=(x=@ ~+(?:((lth x 2) 1 (add $(x (dec x)) $(x (sub x 2))))))
|
||||||
|
--
|
||||||
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
|||||||
::
|
|
||||||
:::: /hoon/core/html/pro
|
|
||||||
::
|
|
||||||
/? 314
|
|
||||||
::
|
|
||||||
:::: compute
|
|
||||||
::
|
|
||||||
|_ htm=@t
|
|
||||||
::
|
|
||||||
++ grow :: convert to
|
|
||||||
|%
|
|
||||||
++ mime :: convert to %mime
|
|
||||||
[/text/html (met 3 htm) htm]
|
|
||||||
--
|
|
||||||
--
|
|
||||||
|
|
@ -155,9 +155,9 @@
|
|||||||
%+ cold ~
|
%+ cold ~
|
||||||
%- full
|
%- full
|
||||||
;~ pose
|
;~ pose
|
||||||
;~(plug (stun [0 3] ace) hep wits hep wits hep (star ;~(pose hep wite)))
|
;~(plug (stun [0 3] ace) hep wits hep wits hep (star ;~(pose hep ace)))
|
||||||
;~(plug (stun [0 3] ace) tar wits tar wits tar (star ;~(pose tar wite)))
|
;~(plug (stun [0 3] ace) tar wits tar wits tar (star ;~(pose tar ace)))
|
||||||
;~(plug (stun [0 3] ace) cab wits cab wits cab (star ;~(pose cab wite)))
|
;~(plug (stun [0 3] ace) cab wits cab wits cab (star ;~(pose cab ace)))
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ html (stag %hem apex:xmlp) :: html barb
|
++ html (stag %hem apex:xmlp) :: html barb
|
||||||
@ -273,9 +273,8 @@
|
|||||||
(plus ;~(pose emph cods link (text fail)))
|
(plus ;~(pose emph cods link (text fail)))
|
||||||
::
|
::
|
||||||
++ text |*(res=_rule (stag %tex (plus ;~(less ;~(pose res dont) chrd))))
|
++ text |*(res=_rule (stag %tex (plus ;~(less ;~(pose res dont) chrd))))
|
||||||
++ whit (mask ~[`@`0x20 `@`0x9 `@`0xa]) :: whitespace w/nl
|
++ whit (mask ~[`@`0x20 `@`0xa]) :: whitespace w/nl
|
||||||
++ wite (mask ~[`@`0x20 `@`0x9]) :: whitespace
|
++ wits (star ace)
|
||||||
++ wits (star wite)
|
|
||||||
--
|
--
|
||||||
::
|
::
|
||||||
++ noun :: convert from %noun
|
++ noun :: convert from %noun
|
16
main/mar/html/door.hook
Normal file
16
main/mar/html/door.hook
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
::
|
||||||
|
:::: /hoon/core/html/pro
|
||||||
|
::
|
||||||
|
/? 314
|
||||||
|
::
|
||||||
|
:::: compute
|
||||||
|
::
|
||||||
|
|_ htm=@t
|
||||||
|
::
|
||||||
|
++ grow :: convert to
|
||||||
|
|% ::
|
||||||
|
++ mime [/text/html (met 3 htm) htm] :: to %mime
|
||||||
|
++ hymn (rash htm apex:xmlp) :: to %hymn
|
||||||
|
-- ::
|
||||||
|
--
|
||||||
|
|
12
main/pub/fab/fun/five/hymn.hook
Normal file
12
main/pub/fab/fun/five/hymn.hook
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/= ctx /$ |=([p=beam q=path] +<)
|
||||||
|
::
|
||||||
|
;html
|
||||||
|
;head
|
||||||
|
;title: Fun Experiment Five
|
||||||
|
==
|
||||||
|
;body
|
||||||
|
;p: This page was built at {<(tope p.ctx)>}.
|
||||||
|
;br;
|
||||||
|
;p: The remainder path was {<q.ctx>}.
|
||||||
|
==
|
||||||
|
==
|
19
main/pub/fab/fun/four/hymn.hook
Normal file
19
main/pub/fab/fun/four/hymn.hook
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/= gas /$ fuel
|
||||||
|
::
|
||||||
|
=+ arg=(biff (~(get by qix.gas) %number) (slat %ud))
|
||||||
|
=+ fib=|=(x=@ ~+(?:((lth x 2) 1 (add $(x (dec x)) $(x (sub x 2))))))
|
||||||
|
::
|
||||||
|
;html
|
||||||
|
;head
|
||||||
|
;title: Fun Experiment Four
|
||||||
|
==
|
||||||
|
;body
|
||||||
|
;p: Welcome, {<cip.ced.gas>}!
|
||||||
|
;+ ?~ arg
|
||||||
|
;p: Usage: ?number=x
|
||||||
|
;p ; This is an ;{i "HTML file"} which
|
||||||
|
; computes the Fibonacci number
|
||||||
|
; of {<u.arg>}: {<(fib u.arg)>}.
|
||||||
|
==
|
||||||
|
==
|
||||||
|
==
|
1
main/pub/fab/fun/one.md
Normal file
1
main/pub/fab/fun/one.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
This is a *fun experiment* in markdown.
|
11
main/pub/fab/fun/three/hymn.hook
Normal file
11
main/pub/fab/fun/three/hymn.hook
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
=+ fib=|=(x=@ ?:((lth x 2) 1 (add $(x (dec x)) $(x (sub x 2)))))
|
||||||
|
;html
|
||||||
|
;head ;title: Fun Experiment Three
|
||||||
|
==
|
||||||
|
;body
|
||||||
|
;p ; This is an ;{i "HTML file"} which
|
||||||
|
; computes the Fibonacci number
|
||||||
|
; of 12: {<(fib 12)>}.
|
||||||
|
==
|
||||||
|
==
|
||||||
|
==
|
5
main/pub/fab/fun/two/down.hook
Normal file
5
main/pub/fab/fun/two/down.hook
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
:~ :- %par
|
||||||
|
:~ tex/"This is a "
|
||||||
|
emp/bent/~[tex/"fun experiment "]
|
||||||
|
tex/"in markdown; 2 + 2 is {<(add 2 2)>}."
|
||||||
|
== ==
|
9
main/pub/fab/mad/five/down.hook
Normal file
9
main/pub/fab/mad/five/down.hook
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/- down
|
||||||
|
^- down
|
||||||
|
:~ :- %par
|
||||||
|
:~ tex/"This is a "
|
||||||
|
emp/bent/~[tex/"fun experiment "]
|
||||||
|
tex/"in markdown; 2 + 2 is {<(add 2 2)>}."
|
||||||
|
== ==
|
||||||
|
|
||||||
|
|
21
main/pub/fab/mad/four/hymn.hook
Normal file
21
main/pub/fab/mad/four/hymn.hook
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
:: This fourth experiment is profoundly biblical.
|
||||||
|
::
|
||||||
|
:::: /hoon/four/mad/fab/pub
|
||||||
|
::
|
||||||
|
/= bible /: /======/res/bible
|
||||||
|
/; |= a=(list (pair ,@ manx))
|
||||||
|
(turn a |=([* b=manx] b))
|
||||||
|
/@
|
||||||
|
/hymn/
|
||||||
|
::
|
||||||
|
:::: ~tasfyn-partyv
|
||||||
|
::
|
||||||
|
!:
|
||||||
|
;html
|
||||||
|
;head
|
||||||
|
;title: Mad Experiment Four
|
||||||
|
==
|
||||||
|
;body
|
||||||
|
;* bible
|
||||||
|
==
|
||||||
|
==
|
25
main/pub/fab/mad/one/hymn.hook
Normal file
25
main/pub/fab/mad/one/hymn.hook
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
:: Our first experiment with major hood runes.
|
||||||
|
::
|
||||||
|
:::: /hoon/one/mad/src/pub
|
||||||
|
::
|
||||||
|
/= gas /$ fuel
|
||||||
|
// /===/pub/src/mad/fib
|
||||||
|
::
|
||||||
|
:::: ~tasfyn-partyv
|
||||||
|
::
|
||||||
|
=+ arg=(biff (~(get by qix.gas) %number) (slat %ud))
|
||||||
|
::
|
||||||
|
;html
|
||||||
|
;head
|
||||||
|
;title: Mad Experiment One
|
||||||
|
==
|
||||||
|
;body
|
||||||
|
;+ ?~ arg
|
||||||
|
;p: Usage: ?number=x
|
||||||
|
;p ; This is an ;{i "HTML file"} which
|
||||||
|
; computes the Fibonacci number
|
||||||
|
; of {<u.arg>}: {<(fib u.arg)>}.
|
||||||
|
==
|
||||||
|
==
|
||||||
|
==
|
||||||
|
|
1
main/pub/fab/mad/res/bible/1.html
Normal file
1
main/pub/fab/mad/res/bible/1.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<p>The earth was without form, and void.</p>
|
1
main/pub/fab/mad/res/bible/2.html
Normal file
1
main/pub/fab/mad/res/bible/2.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<p>Then Cain slew Abel.</p>
|
1
main/pub/fab/mad/res/bible/3.html
Normal file
1
main/pub/fab/mad/res/bible/3.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<p>I bring not peace, but a sword.</p>
|
1
main/pub/fab/mad/res/bible/4.html
Normal file
1
main/pub/fab/mad/res/bible/4.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<p>And I saw a pale horse, and upon him a pale rider.</p>
|
1
main/pub/fab/mad/res/hello/hymn.hook
Normal file
1
main/pub/fab/mad/res/hello/hymn.hook
Normal file
@ -0,0 +1 @@
|
|||||||
|
;p: Hello, world.
|
23
main/pub/fab/mad/six/hymn.hook
Normal file
23
main/pub/fab/mad/six/hymn.hook
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
:: Our sixth experiment with major hood runes.
|
||||||
|
::
|
||||||
|
:::: /hoon/six/mad/fab/pub
|
||||||
|
::
|
||||||
|
/+ example
|
||||||
|
/= gas /$ fuel
|
||||||
|
::
|
||||||
|
:::: ~tasfyn-partyv
|
||||||
|
::
|
||||||
|
=+ arg=(biff (~(get by qix.gas) %number) (slat %ud))
|
||||||
|
;html
|
||||||
|
;head
|
||||||
|
;title: Mad Experiment Two
|
||||||
|
==
|
||||||
|
;body
|
||||||
|
;+ ?~ arg
|
||||||
|
;p: Usage: ?number=x
|
||||||
|
;p ; This is an ;{i "HTML file"} which
|
||||||
|
; computes the Fibonacci number
|
||||||
|
; of {<u.arg>}: {<(fib u.arg)>}.
|
||||||
|
==
|
||||||
|
==
|
||||||
|
==
|
17
main/pub/fab/mad/three/hymn.hook
Normal file
17
main/pub/fab/mad/three/hymn.hook
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
:: This third experiment wears the horns.
|
||||||
|
::
|
||||||
|
:::: /hoon/three/mad/fab/pub
|
||||||
|
::
|
||||||
|
/= hello /^ manx /:/======/res/hello:/hymn/
|
||||||
|
::
|
||||||
|
:::: ~tasfyn-partyv
|
||||||
|
::
|
||||||
|
;html
|
||||||
|
;head
|
||||||
|
;title: Mad Experiment Three
|
||||||
|
==
|
||||||
|
;body
|
||||||
|
;+ hello
|
||||||
|
==
|
||||||
|
==
|
||||||
|
|
25
main/pub/fab/mad/two/hymn.hook
Normal file
25
main/pub/fab/mad/two/hymn.hook
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
:: Our second experiment with major hood runes.
|
||||||
|
::
|
||||||
|
:::: /hoon/two/mad/src/pub
|
||||||
|
::
|
||||||
|
/= gas /$ fuel
|
||||||
|
// /===/pub/src/mad/tools
|
||||||
|
::
|
||||||
|
:::: ~tasfyn-partyv
|
||||||
|
::
|
||||||
|
=+ arg=(biff (~(get by qix.gas) %number) (slat %ud))
|
||||||
|
::
|
||||||
|
;html
|
||||||
|
;head
|
||||||
|
;title: Mad Experiment Two
|
||||||
|
==
|
||||||
|
;body
|
||||||
|
;+ ?~ arg
|
||||||
|
;p: Usage: ?number=x
|
||||||
|
;p ; This is an ;{i "HTML file"} which
|
||||||
|
; computes the Fibonacci number
|
||||||
|
; of {<u.arg>}: {<(fib u.arg)>}.
|
||||||
|
==
|
||||||
|
==
|
||||||
|
==
|
||||||
|
|
@ -607,13 +607,67 @@ original **subject** and the new variable.
|
|||||||
|
|
||||||
35 :: *[a 9 b c] *[a 7 c 2 [0 1] 0 b]
|
35 :: *[a 9 b c] *[a 7 c 2 [0 1] 0 b]
|
||||||
|
|
||||||
**Operator 9** takes a **subject** and produces a new **subject** containing both code and data, also known as a **core**. A formula is then both extracted from, and applied to this new **core** **subject**. As its breakdown demonstrates, **Operator 9** is a macro that can compose recursive functions, as it encapsulates the functionality of both **Operator 7**(function composition) and **Operator 2** (recursion).
|
**Operator 9** takes a **subject** and produces a new **subject** containing
|
||||||
|
both code and data. A formula is then extracted, and then reflexively applied
|
||||||
|
to this newly generated **subject**. A subject of this structure, `[code
|
||||||
|
data]`, is officially called a **core**, in which code and data are renamed
|
||||||
|
**battery** and **payload**, respectively. **Cores** allow us to carry around
|
||||||
|
data structures that contain both code and data; **Operator 9** allows for code
|
||||||
|
from within the **battery** of a **core** to then be applied to data from
|
||||||
|
within the **payload** of that same **core**.
|
||||||
|
|
||||||
|
There are different names for several different classes of **cores**: a
|
||||||
|
**door** is any **core** whose **payload** is of the form `[sample context]`,
|
||||||
|
where the **sample** is the argument (or arguments), and the **context** is any
|
||||||
|
other code available to be called. For almost every expression, the context
|
||||||
|
contains at least the entire kernel. The **battery** of a **door** contains one
|
||||||
|
or more **arms**, which are formulas that, when called, can produce a **gate**,
|
||||||
|
another type of **core** whose **battery** has just one arm of an empty name,
|
||||||
|
**++$**, called **buc** (++ is used to denote **arms** in Hoon), with a payload of `[sample context]`. **Gates** are
|
||||||
|
the closest thing Nock and Hoon have to functions in the traditional FP sense.
|
||||||
|
|
||||||
|
Take, for example, a **door** with a **battery** of two arms, **++add** and
|
||||||
|
**++subtract**, a **payload** with a
|
||||||
|
**sample** **cell** of `[43 40]`, and a **context** consisting of the entire
|
||||||
|
kernel. If **Operator 9** were used to pull the address of the **arm**
|
||||||
|
**++subtract** from within this **door's** battery of **arms**, **++subtract**
|
||||||
|
would produce a new **core** by pushing both an **arm**, **++$**--which would
|
||||||
|
contain the code that, when called, would actually execute the subtraction--and
|
||||||
|
a new sample onto the **subject**. The **context** of this new **gate** would
|
||||||
|
be the previous **door** from which the **gate** was generated.
|
||||||
|
|
||||||
|
The pseudocode below demonstrates this clearly:
|
||||||
|
|
||||||
|
Door:
|
||||||
|
|
||||||
|
[[subtract add] [[43 40] [kernel]]]
|
||||||
|
[Battery [Sample Context ]]
|
||||||
|
|
||||||
|
Operator 9, calling subtract
|
||||||
|
|
||||||
|
[[$, with the executable subtract code] [[43 40] [[subtract add] [[43 40] [kernel]]]]]
|
||||||
|
[[ Formula [[Sample][ Context (former door) ]]]]
|
||||||
|
|
||||||
|
If **$** is called from within this new gate, it will subtract `40` from `43`.
|
||||||
|
However, some may notice the definition of **subtract** contains calls to
|
||||||
|
**decrement**. How does it gain access this function? The **decrement** arm is
|
||||||
|
contained within the **context** inside of the kernel.
|
||||||
|
|
||||||
|
As its breakdown demonstrates, **Operator 9** is a macro that encapsulates the
|
||||||
|
functionality of both **Operator 7** (function composition) and **Operator 2**
|
||||||
|
(recursion). It produces a **core**, from whose **battery** an **arm** (or **arms**) is
|
||||||
|
extracted. These **arm(s)** are then reflexively applied to this new **core**.
|
||||||
|
|
||||||
The reduced pseudo code demonstrates this clearly:
|
The reduced pseudo code demonstrates this clearly:
|
||||||
|
|
||||||
*[*[a c] *[*[a c] 0 b]]
|
*[*[a c] *[*[a c] 0 b]]
|
||||||
|
|
||||||
Here, `c` is some formula that produces a **core** when applied to **subject** `a`. This new **core** is then paired with a formula extracted from **axis** `b` within an identical copy of the new **core**. In higher-level languages that compile to Nock, functions that loop recursively often generate **Operator 9**, as it is the most concise way for a function (or **gate**, to use proper Hoon technology) to recall itself with changes made to its data.
|
Here, `c` is some formula that produces a **core** when applied to **subject**
|
||||||
|
`a`. This new **core** is then paired with a formula extracted from **axis**
|
||||||
|
`b` within an identical copy of the new **core**. In higher-level languages
|
||||||
|
that compile to Nock, functions that loop recursively often generate **Operator
|
||||||
|
9**, as it is the most concise way for a function (or **gate**, to use proper
|
||||||
|
Hoon technology) to recall itself with changes made to its data.
|
||||||
|
|
||||||
|
|
||||||
##Op 10: Hint
|
##Op 10: Hint
|
||||||
@ -623,17 +677,33 @@ Here, `c` is some formula that produces a **core** when applied to **subject** `
|
|||||||
|
|
||||||
**Operator 10** serves as a hint to the interpreter.
|
**Operator 10** serves as a hint to the interpreter.
|
||||||
|
|
||||||
As shown above, there are two cases of **Operator 10**. The latter has the formula `[10 b c]`, which then simply reduces to `c`. Although `[10 b c]` has to be semantically equivalent to `c`, it doesn't have to be practically equivalent. Since whatever information in `b` is discarded, a practical interpreter is free to ignore it, or to use it as a hint, as long as it does not affect the results of the computation.
|
If `b` is an atom and `c` is a **formula**, the **formula** `[10 b c]` appears
|
||||||
|
to be equivalent to `c`. Likewise if `[b c]` is a **cell**, `[10 [b c] d]`
|
||||||
The former case is slightly more complicated. While it may appear that its reduction `*[*[[*[a c] a] 0 3] d]` could be reduced further to simply `[a d]`, as `*[[*[a c] a] 0 3]` could seem to return just `a`. However, there is a possibility that `c` does not terminate, in which case `[a d]` would be incorrect. Therefore, `*[*[[*[a c] a] 0 3] d]` is the most this case can be reduced. This is because **Operator 10** is a hint. If `x` in `[10 x y]` is an atom, we reduce line 37 and `x` is simply discarded. Otherwise, `x` is a cell `[b c]`; b is discarded, but `c` is computed as a formula and its result is discarded.
|
appears to be equivalent to `d`. **Operator 10** is actually a hint operator.
|
||||||
|
The `b` or `[b c]`is discarded information - it is not used, formally, in the
|
||||||
Effectively, this mechanism lets us feed both static and dynamic information into the interpreter's hint mechanism.
|
computation. It may help the interpreter compute the expression more
|
||||||
|
efficiently, however.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Every Nock computes the same result - but not all at the same speed. What hints
|
||||||
|
are supported? What do they do? Hints are a higher-level convention which do
|
||||||
|
not, and should not, appear in the Nock spec. Some are defined in Hoon. Indeed,
|
||||||
|
a naive Nock interpreter not optimized for Hoon will run Hoon quite poorly.
|
||||||
|
When it gets the product, however, the product will be right. (Why is the `c`
|
||||||
|
in `[b c]` computed? Because `c` could crash. A correct Nock cannot simply
|
||||||
|
ignore it, and treat both variants of `10` as equivalent.)
|
||||||
|
|
||||||
|
|
||||||
##Crash default
|
##Crash default
|
||||||
|
|
||||||
39 :: *a *a
|
39 :: *a *a
|
||||||
|
|
||||||
|
The nock function is defined for every **noun**, but on many **nouns** it does nothing
|
||||||
|
useful. For instance, if `a` is an **atom**, `*a` reduces to... `*a`. In theory, this
|
||||||
|
means that Nock spins forever in an infinite loop. In other words, Nock
|
||||||
|
produces no result - and in practice, your interpreter will stop.
|
||||||
|
|
||||||
|
(Another way to see this is that Nock has "crash-only" semantics. There is no
|
||||||
|
exception mechanism. The only way to catch Nock errors is to simulate Nock in a
|
||||||
|
higher-level virtual Nock - which, in fact, we do all the time. A simulator (or
|
||||||
|
a practical low-level interpreter) can report, out of band, that Nock would not
|
||||||
|
terminate. It cannot recognize all in.
|
||||||
|
@ -402,27 +402,39 @@ Section 2bA, units
|
|||||||
! exit
|
! exit
|
||||||
|
|
||||||
++ need
|
++ need
|
||||||
Retrieve the value from a unit, crashing if the unit is null.
|
|
||||||
---
|
Retrieve the value from a unit and crash if the unit is null.
|
||||||
Build wet %gold gate with sample unit a of any type.
|
|
||||||
If: p is null,
|
####Summary
|
||||||
|
|
||||||
|
Build wet %gold gate with sample unit `a` of any type.
|
||||||
|
If: p is null,
|
||||||
Then: fail,
|
Then: fail,
|
||||||
Else: u.a, the value of the unit.
|
Else: Produce u.a, the value of the unit.
|
||||||
---
|
|
||||||
~divreg-misdef/try=> =a ((unit ,[@t @t]) [~ [`a` ' b']])
|
####Examples
|
||||||
~divreg-misdef/try=> (need a)
|
|
||||||
[`a` ' b']
|
~zod/try=> =a ((unit ,[@t @t]) [~ ['a' 'b']])
|
||||||
~divreg-misdef/try=> =a ((unit ,@) [~])
|
~zod/try=> (need a)
|
||||||
~divreg-misdef/try=> (need a)
|
['a' 'b']
|
||||||
|
~zod/try=> =a ((unit ,@ud) [~ 17])
|
||||||
|
~zod/try=> (need a)
|
||||||
|
17
|
||||||
|
~zod/try=> =a ((unit ,@) [~])
|
||||||
|
~zod/try=> (need a)
|
||||||
! exit
|
! exit
|
||||||
++ some
|
|
||||||
lift
|
++ some
|
||||||
Description:
|
|
||||||
Casts any noun a to its unit, [~ a].
|
Casts any noun a to its unit, [~ a].
|
||||||
---
|
|
||||||
Creates a wet %gold gate with a sample which accepts any noun.
|
####Summary
|
||||||
Produces the tuple [~ u=a], the unit of value a.
|
|
||||||
Examples:
|
Build wet %gold gate with sample noun `a`.
|
||||||
|
Produce the tuple [~ u=a], the unit of value `a`.
|
||||||
|
|
||||||
|
####Examples
|
||||||
|
|
||||||
~divreg-misdef/try=> (some [`a` `b`])
|
~divreg-misdef/try=> (some [`a` `b`])
|
||||||
[~ u=[`a` `b`]]
|
[~ u=[`a` `b`]]
|
||||||
---
|
---
|
||||||
@ -432,29 +444,31 @@ Section 2bA, units
|
|||||||
Section 2bB, lists
|
Section 2bB, lists
|
||||||
|
|
||||||
++ flop
|
++ flop
|
||||||
reverse
|
|
||||||
Description:
|
Produces the list 'a' with the elements reversed.
|
||||||
Produces the list 'a' with the elements reversed.
|
|
||||||
---
|
####Summary
|
||||||
|
|
||||||
Activate jet.
|
Activate jet.
|
||||||
Creates a wet %gold gate with a sample which accepts a single list.
|
Build wet %gold gate with sample list `a`.
|
||||||
'a' is then replaced with (homo a) and used as the subject for the code below (=>).
|
Use `a` replaced by the slam of `a` to homo, the homogenized list, as subject.
|
||||||
The type of the result must be the same as a, our argument list.
|
Cast the following to the type of `a`.
|
||||||
Let b be a list of the type of the icon of a, as it is bunted.
|
Push `b` is the
|
||||||
Create and kick a dry %gold trap
|
Kick dry %gold gate trap.
|
||||||
Builds an if-then-else statement on "a is an atom."
|
If: `a` is null,
|
||||||
If so, produce b.
|
Then: Produce `b`,
|
||||||
Else, recursively call flop with a replaced by it's tail and b replaced by [i.a b], where
|
Else: Produce the toss of `a` for the tail of `a`, `b` for the cell [i.a b].
|
||||||
i.a is the head of a.
|
|
||||||
Examples:
|
####Examples
|
||||||
|
|
||||||
~palryp-hocsyt/try=> =lyst (limo [1 2 3 4 ~])
|
~palryp-hocsyt/try=> =lyst (limo [1 2 3 4 ~])
|
||||||
~palryp-hocsyt/try=> lyst
|
~palryp-hocsyt/try=> lyst
|
||||||
[i=1 t=[i=2 t=[i=3 t=[i=4 t=~]]]]
|
[i=1 t=[i=2 t=[i=3 t=[i=4 t=~]]]]
|
||||||
~palryp-hocsyt/try=> (flop lyst)
|
~palryp-hocsyt/try=> (flop lyst)
|
||||||
~[4 3 2 1]
|
~[4 3 2 1]
|
||||||
---
|
|
||||||
~palryp-hocsyt/try=> (flop (limo [1 'a' 2 'b' (some 10) ~]))
|
~palryp-hocsyt/try=> (flop (limo [1 'a' 2 'b' (some 10) ~]))
|
||||||
~[[~ u=10] 98 2 97 1]
|
~[[~ u=10] 98 2 97 1]
|
||||||
|
|
||||||
++ homo
|
++ homo
|
||||||
homogenize
|
homogenize
|
||||||
Description:
|
Description:
|
||||||
|
3
main/pub/src/mad/fib.hoon
Normal file
3
main/pub/src/mad/fib.hoon
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
|%
|
||||||
|
++ fib |=(x=@ ~+(?:((lth x 2) 1 (add $(x (dec x)) $(x (sub x 2))))))
|
||||||
|
--
|
1
main/pub/src/mad/tools/fib.hoon
Normal file
1
main/pub/src/mad/tools/fib.hoon
Normal file
@ -0,0 +1 @@
|
|||||||
|
|=(x=@ ~+(?:((lth x 2) 1 (add $(x (dec x)) $(x (sub x 2))))))
|
@ -4,3 +4,4 @@
|
|||||||
/? 314
|
/? 314
|
||||||
/- *markdown
|
/- *markdown
|
||||||
down
|
down
|
||||||
|
|
||||||
|
@ -19,3 +19,4 @@
|
|||||||
[%tex p=tape] :: text
|
[%tex p=tape] :: text
|
||||||
== ::
|
== ::
|
||||||
--
|
--
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user