This commit is contained in:
John Dulin 2014-08-05 16:50:08 -07:00
commit 3cf31e7dc1
46 changed files with 405 additions and 581 deletions

View File

@ -298,9 +298,17 @@
?: =(~ mog) luv
?+ -.luv luv
%mid
=+ str=(trip q.q.luv)
=+ scr=|-(^-(tape ?~(mog ~ (xmlt & i.mog $(mog t.mog)))))
=+ rep=(need (repg "<head data-scr=\"true\">" str (weld "<head data-scr=\"true\">" scr)))
?. =('<html' (end 3 5 q.q.luv)) luv
=+ scr=(roll mog |=([a=manx b=tape] (xmlt & a b)))
=+ ^= 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)]
==
++ lofe :: variables in head

View File

@ -19,30 +19,30 @@
== ::
++ hood :: assembly plan
$: zus=@ud :: zuse kelvin
sur=(list hook) :: structures
sur=(list hoot) :: structures
lib=(list hoof) :: libraries
fan=(list horn) :: resources
src=(list hoop) :: program
== ::
++ 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
$% [%& p=twig] :: direct twig
[%| p=beam] :: resource location
== ::
++ horn :: resource tree
$% [%and p=twig] :: /& twig by hand
$% [%ape p=twig] :: /& twig by hand
[%arg p=twig] :: /$ argument
[%day p=horn] :: /| @dr map by @dr
[%day p=horn] :: /| list by @dr
[%dub p=term q=horn] :: /= apply face
[%fan p=(list horn)] :: /: list
[%fan p=(list horn)] :: /. list
[%for p=path q=horn] :: /, descend
[%hub p=horn] :: /@ map by @ud
[%man p=(map term horn)] :: /* map by hand
[%nap p=horn] :: /% map by @tas
[%now p=horn] :: /& map by @da
[%hub p=horn] :: /@ list by @ud
[%man p=(map span horn)] :: /* hetero map
[%nap p=horn] :: /% homo map
[%now p=horn] :: /& list by @da
[%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
[%toy p=mark] :: /mark/ static
== ::
@ -209,9 +209,13 @@
|= kus=(unit silk)
^+ +>
?~ kus
=+ nym=(~(get by dym.bay) hen)
?~ nym :: XX should never
~& [%ford-mystery hen]
+>.$
=+ num=(need (~(get by dym.bay) hen))
=+ tas=(need (~(get by q.tad.bay) num))
amok:~(camo zo [num tas])
=+ tas=(need (~(get by q.tad.bay) u.nym))
amok:~(camo zo [u.nym tas])
=+ num=p.tad.bay
?> !(~(has by dym.bay) hen)
=: p.tad.bay +(p.tad.bay)
@ -409,7 +413,7 @@
++ fang :: protocol door
|= [cof=cafe for=mark bek=beak]
^- (bolt vase)
=+ pax=/door/[for]/mac
=+ pax=/door/[for]/mar
=+ ^= bem ^- beam
:_ pax
?: =(p.bek our) bek
@ -443,7 +447,7 @@
==
::
;~ pose
(ifix [;~(plug fas hep gap) gap] (most ;~(plug com gaw) hook))
(ifix [;~(plug fas hep gap) gap] (most ;~(plug com gaw) hoot))
(easy ~)
==
::
@ -467,7 +471,7 @@
==
==
::
++ hook
++ hoot
;~ pose
(stag %| ;~(pfix tar hoof))
(stag %& hoof)
@ -488,8 +492,8 @@
;~ pfix fas
;~ pose
(stag %toy ;~(sfix sym fas))
(stag %and ;~(pfix and:sign and:read))
(stag %arg ;~(pfix arg:sign and:read))
(stag %ape ;~(pfix ape:sign ape:read))
(stag %arg ;~(pfix arg:sign ape:read))
(stag %day ;~(pfix day:sign day:read))
(stag %dub ;~(pfix dub:sign dub:read))
(stag %fan ;~(pfix fan:sign fan:read))
@ -498,6 +502,7 @@
(stag %man ;~(pfix man:sign man:read))
(stag %nap ;~(pfix nap:sign day:read))
(stag %now ;~(pfix now:sign day:read))
(stag %saw ;~(pfix saw:sign saw:read))
(stag %see ;~(pfix see:sign see:read))
(stag %sic ;~(pfix sic:sign sic:read))
==
@ -509,7 +514,7 @@
;~(pose wid tal)
::
++ read
|% ++ and
|% ++ ape
%+ rail
(ifix [sel ser] (stag %cltr (most ace wide:vez)))
;~(pfix gap tall:vez)
@ -546,28 +551,33 @@
::
++ see
%+ rail
;~(plug (ifix [sel ser] have) apex(tol |))
;~(plug ;~(sfix have col) apex(tol |))
;~(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
%+ rail
;~(plug (ifix [sel ser] toil:vez) apex(tol |))
;~(plug ;~(sfix toil:vez ket) apex(tol |))
;~(pfix gap ;~(plug howl:vez ;~(pfix gap apex)))
--
::
++ sign
|% ++ and ;~(pose pam (jest %and))
|% ++ ape ;~(pose sig (jest %ape))
++ arg ;~(pose buc (jest %arg))
++ day ;~(pose bar (jest %day))
++ dub ;~(pose tis (jest %dub))
++ fan ;~(pose col (jest %fan))
++ fan ;~(pose dot (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))
++ see ;~(pose col (jest %see))
++ sic ;~(pose ket (jest %sic))
--
--
@ -963,40 +973,62 @@
|= [cof=cafe sel=_..body]
^$(cof cof, src t.src, ..body sel)
::
++ chai :: atomic map
++ chad :: atomic list
|= [cof=cafe bax=vase doe=term hon=horn]
^- (bolt vase)
%+ cope ((lash (slat doe)) cof how)
|= [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
|- ^- (bolt (map ,@ vase))
?~ yep (fine cof ~)
%+ cope $(yep l.yep)
?~ r.arc (fine cof ~)
%+ cope $(r.arc l.r.arc)
|= [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)]
%+ 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]
(fine cof [[p.n.yep nod] lef rig])
(fine cof [[p.n.r.arc nod] lef rig])
|= [cof=cafe doy=(map ,@ vase)]
%+ fine cof
|- ^- vase
?~ doy [[%cube 0 [%atom %n]] 0]
%+ 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))
::
++ chap :: produce resources
|= [cof=cafe bax=vase hon=horn]
^- (bolt vase)
?- -.hon
%and (maim cof bax p.hon)
%ape (maim cof bax p.hon)
%arg
%+ cope (maim cof bax p.hon)
|= [cof=cafe gat=vase]
(maul cof gat !>([how arg]))
::
%day (chai cof bax %dr p.hon)
%day (chad cof bax %dr p.hon)
%dub
%+ cope $(hon q.hon)
|= [cof=cafe vax=vase]
@ -1018,7 +1050,7 @@
(slop i.tev $(tev t.tev))
::
%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
|- ^- (bolt vase)
?~ p.hon (fine cof [[%cube 0 [%atom %n]] 0])
@ -1033,9 +1065,8 @@
(slop [[%atom %tas] p.n.p.hon] vax)
(slop lef rig)
::
%now (chai cof bax %da p.hon)
%nap (chai cof bax %tas p.hon)
::
%now (chad cof bax %da p.hon)
%nap (chai cof bax p.hon)
%see $(hon q.hon, how p.hon)
%saw
%+ cope $(hon q.hon)
@ -1051,13 +1082,13 @@
|= [cof=cafe tug=vase]
?. (~(nest ut p.tug) | p.vax)
(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)
==
::
++ head :: consume structures
|= [cof=cafe bir=(list hook)]
|= [cof=cafe bir=(list hoot)]
|- ^- (bolt ,_..head)
?~ bir
(fine cof ..head)

View File

@ -9889,7 +9889,7 @@
%pass
~? &(!lac !=(%$ p.gum))
:^ %pass [p.gum p.q.r.gum]
[(,@tas -.q.gum) p.r.gum]
[(,@tas +>-.q.q.r.gum) p.r.gum]
q.gum
[p.q.r.gum ~ [[p.gum p.r.gum] q.gum] q.q.r.gum]
::

View File

@ -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
View 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}))
; }
==
==
==
--

View File

@ -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]
==
--

View File

@ -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')
})
}

View File

@ -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))
==
--

View File

@ -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)
})
}
}

View File

@ -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 ~
--

View File

@ -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]
==
--

View File

@ -0,0 +1,5 @@
|%
++ fib |=(x=@ ~+(?:((lth x 2) 1 (add $(x (dec x)) $(x (sub x 2))))))
--

View File

@ -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]
--
--

View File

@ -155,9 +155,9 @@
%+ cold ~
%- full
;~ pose
;~(plug (stun [0 3] ace) hep wits hep wits hep (star ;~(pose hep wite)))
;~(plug (stun [0 3] ace) tar wits tar wits tar (star ;~(pose tar wite)))
;~(plug (stun [0 3] ace) cab wits cab wits cab (star ;~(pose cab 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 ace)))
;~(plug (stun [0 3] ace) cab wits cab wits cab (star ;~(pose cab ace)))
==
::
++ html (stag %hem apex:xmlp) :: html barb
@ -273,9 +273,8 @@
(plus ;~(pose emph cods link (text fail)))
::
++ text |*(res=_rule (stag %tex (plus ;~(less ;~(pose res dont) chrd))))
++ whit (mask ~[`@`0x20 `@`0x9 `@`0xa]) :: whitespace w/nl
++ wite (mask ~[`@`0x20 `@`0x9]) :: whitespace
++ wits (star wite)
++ whit (mask ~[`@`0x20 `@`0xa]) :: whitespace w/nl
++ wits (star ace)
--
::
++ noun :: convert from %noun

16
main/mar/html/door.hook Normal file
View 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
-- ::
--

View 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>}.
==
==

View 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
View File

@ -0,0 +1 @@
This is a *fun experiment* in markdown.

View 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)>}.
==
==
==

View File

@ -0,0 +1,5 @@
:~ :- %par
:~ tex/"This is a "
emp/bent/~[tex/"fun experiment "]
tex/"in markdown; 2 + 2 is {<(add 2 2)>}."
== ==

View 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)>}."
== ==

View 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
==
==

View 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)>}.
==
==
==

View File

@ -0,0 +1 @@
<p>The earth was without form, and void.</p>

View File

@ -0,0 +1 @@
<p>Then Cain slew Abel.</p>

View File

@ -0,0 +1 @@
<p>I bring not peace, but a sword.</p>

View File

@ -0,0 +1 @@
<p>And I saw a pale horse, and upon him a pale rider.</p>

View File

@ -0,0 +1 @@
;p: Hello, world.

View 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)>}.
==
==
==

View 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
==
==

View 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)>}.
==
==
==

View File

@ -607,13 +607,67 @@ original **subject** and the new variable.
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:
*[*[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
@ -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.
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.
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.
Effectively, this mechanism lets us feed both static and dynamic information into the interpreter's hint mechanism.
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]`
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
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
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.

View File

@ -0,0 +1,3 @@
|%
++ fib |=(x=@ ~+(?:((lth x 2) 1 (add $(x (dec x)) $(x (sub x 2))))))
--

View File

@ -0,0 +1 @@
|=(x=@ ~+(?:((lth x 2) 1 (add $(x (dec x)) $(x (sub x 2))))))

View File

@ -4,3 +4,4 @@
/? 314
/- *markdown
down

View File

@ -19,3 +19,4 @@
[%tex p=tape] :: text
== ::
--