Remove unused generators

This commit is contained in:
Elliot Glaysher 2018-12-10 16:34:36 -08:00
parent 3153e8882b
commit cb9939f021
4 changed files with 0 additions and 2085 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,486 +0,0 @@
=> |%
::
++ system
$: rec/(map @ud theory)
say/theory
==
++ library
::
++ theory
$@ $? $void
$path
$noun
$hoon
$wall
$text
$tape
$cord
$null
$term
$type
$tank
==
$% {$list item/theory}
{$pole item/theory}
{$set item/theory}
{$map key/theory value/theory}
{$soft type/type data/theory}
{$tuple items/(list theory)}
{$label name/term data/theory}
{$tree item/theory}
{$help writ/writ theory/theory}
{$gate from/theory to/theory}
:: {$core library/}
{$unit item/theory}
{$atom aura/aura}
{$choice cases/(list theory)}
{$branch atom/theory cell/theory}
{$bridge double/theory single/theory}
{$switch cases/(list {stem/theory bulb/theory})}
{$constant aura/aura value/@}
{$pair p/theory q/theory}
{$trel p/theory q/theory r/theory}
{$qual p/theory q/theory r/theory s/theory}
{$quil p/theory q/theory r/theory s/theory t/theory}
--
|%
++ py
++ us :: prettyprinter
=> |%
++ cape {p/(map @ud wine) q/wine} ::
++ wine ::
$@ $? $noun ::
$path ::
$type ::
$void ::
$wall ::
$wool ::
$yarn ::
== ::
$% {$mato p/term} ::
{$core p/(list @ta) q/wine} ::
{$face p/term q/wine} ::
{$list p/term q/wine} ::
{$pear p/term q/@} ::
{$bcwt p/(list wine)} ::
{$plot p/(list wine)} ::
{$stop p/@ud} ::
{$tree p/term q/wine} ::
{$unit p/term q/wine} ::
== ::
--
|_ sut/type
++ dash
|= {mil/tape lim/char} ^- tape
:- lim
|- ^- tape
?~ mil [lim ~]
?: =(lim i.mil) ['\\' i.mil $(mil t.mil)]
?: =('\\' i.mil) ['\\' i.mil $(mil t.mil)]
?: (lte ' ' i.mil) [i.mil $(mil t.mil)]
['\\' ~(x ne (rsh 2 1 i.mil)) ~(x ne (end 2 1 i.mil)) $(mil t.mil)]
::
++ deal |=(lum/* (dish dole lum))
++ dial
|= ham/cape
=+ gid=*(set @ud)
=< `tank`-:$
|%
++ many
|= haz/(list wine)
^- {(list tank) (set @ud)}
?~ haz [~ gid]
=^ mor gid $(haz t.haz)
=^ dis gid ^$(q.ham i.haz)
[[dis mor] gid]
::
++ $
^- {tank (set @ud)}
?- q.ham
$noun :_(gid [%leaf '*' ~])
$path :_(gid [%leaf '/' ~])
$type :_(gid [%leaf '#' 't' ~])
$void :_(gid [%leaf '#' '!' ~])
$wool :_(gid [%leaf '*' '"' '"' ~])
$wall :_(gid [%leaf '*' '\'' '\'' ~])
$yarn :_(gid [%leaf '"' '"' ~])
{$mato *} :_(gid [%leaf '@' (trip p.q.ham)])
{$core *}
=^ cox gid $(q.ham q.q.ham)
:_ gid
:+ %rose
[[' ' ~] ['<' ~] ['>' ~]]
|- ^- (list tank)
?~ p.q.ham [cox ~]
[[%leaf (rip 3 i.p.q.ham)] $(p.q.ham t.p.q.ham)]
::
{$face *}
=^ cox gid $(q.ham q.q.ham)
:_(gid [%palm [['/' ~] ~ ~ ~] [%leaf (trip p.q.ham)] cox ~])
::
{$list *}
=^ cox gid $(q.ham q.q.ham)
:_(gid [%rose [" " (weld (trip p.q.ham) "(") ")"] cox ~])
::
{$bcwt *}
=^ coz gid (many p.q.ham)
:_(gid [%rose [[' ' ~] ['?' '(' ~] [')' ~]] coz])
::
{$plot *}
=^ coz gid (many p.q.ham)
:_(gid [%rose [[' ' ~] ['{' ~] ['}' ~]] coz])
::
{$pear *}
:_(gid [%leaf '$' ~(rend co [%$ p.q.ham q.q.ham])])
::
{$stop *}
=+ num=~(rend co [%$ %ud p.q.ham])
?: (~(has in gid) p.q.ham)
:_(gid [%leaf '#' num])
=^ cox gid
%= $
gid (~(put in gid) p.q.ham)
q.ham (~(got by p.ham) p.q.ham)
==
:_(gid [%palm [['.' ~] ~ ~ ~] [%leaf ['^' '#' num]] cox ~])
::
{$tree *}
=^ cox gid $(q.ham q.q.ham)
:_(gid [%rose [" " (weld (trip p.q.ham) "(") ")"] cox ~])
::
{$unit *}
=^ cox gid $(q.ham q.q.ham)
:_(gid [%rose [" " (weld (trip p.q.ham) "(") ")"] cox ~])
==
--
::
++ dish
|= {ham/cape lum/*} ^- tank
~| [%dish-h ?@(q.ham q.ham -.q.ham)]
~| [%lump lum]
~| [%ham ham]
%- need
=| gil/(set {@ud *})
|- ^- (unit tank)
?- q.ham
$noun
%= $
q.ham
?: ?=(@ lum)
[%mato %$]
:- %plot
|- ^- (list wine)
[%noun ?:(?=(@ +.lum) [[%mato %$] ~] $(lum +.lum))]
==
::
$path
:- ~
:+ %rose
[['/' ~] ['/' ~] ~]
|- ^- (list tank)
?~ lum ~
?@ lum !!
?> ?=(@ -.lum)
[[%leaf (rip 3 -.lum)] $(lum +.lum)]
::
$type
=+ tyr=|.((dial dole))
=+ vol=tyr(sut lum)
=+ cis=((hard tank) .*(vol -:vol))
:^ ~ %palm
[~ ~ ~ ~]
[[%leaf '#' 't' '/' ~] cis ~]
::
$wall
:- ~
:+ %rose
[[' ' ~] ['<' '|' ~] ['|' '>' ~]]
|- ^- (list tank)
?~ lum ~
?@ lum !!
[[%leaf (trip ((hard @) -.lum))] $(lum +.lum)]
::
$wool
:- ~
:+ %rose
[[' ' ~] ['<' '<' ~] ['>' '>' ~]]
|- ^- (list tank)
?~ lum ~
?@ lum !!
[(need ^$(q.ham %yarn, lum -.lum)) $(lum +.lum)]
::
$yarn
[~ %leaf (dash (tape lum) '"')]
::
$void
~
::
{$mato *}
?. ?=(@ lum)
~
:+ ~
%leaf
?+ (rash p.q.ham ;~(sfix (cook crip (star low)) (star hig)))
~(rend co [%$ p.q.ham lum])
$$ ~(rend co [%$ %ud lum])
$t (dash (rip 3 lum) '\'')
$tas ['%' ?.(=(0 lum) (rip 3 lum) ['$' ~])]
==
::
{$core *}
:: XX needs rethinking for core metal
:: ?. ?=(^ lum) ~
:: => .(lum `*`lum)
:: =- ?~(tok ~ [~ %rose [[' ' ~] ['<' ~] ['>' ~]] u.tok])
:: ^= tok
:: |- ^- (unit (list tank))
:: ?~ p.q.ham
:: =+ den=^$(q.ham q.q.ham)
:: ?~(den ~ [~ u.den ~])
:: =+ mur=$(p.q.ham t.p.q.ham, lum +.lum)
:: ?~(mur ~ [~ [[%leaf (rip 3 i.p.q.ham)] u.mur]])
[~ (dial ham)]
::
{$face *}
=+ wal=$(q.ham q.q.ham)
?~ wal
~
[~ %palm [['=' ~] ~ ~ ~] [%leaf (trip p.q.ham)] u.wal ~]
::
{$list *}
?: =(~ lum)
[~ %leaf '~' ~]
=- ?~ tok
~
[~ %rose [[' ' ~] ['~' '[' ~] [']' ~]] u.tok]
^= tok
|- ^- (unit (list tank))
?: ?=(@ lum)
?.(=(~ lum) ~ [~ ~])
=+ [for=^$(q.ham q.q.ham, lum -.lum) aft=$(lum +.lum)]
?. &(?=(^ for) ?=(^ aft))
~
[~ u.for u.aft]
::
{$bcwt *}
|- ^- (unit tank)
?~ p.q.ham
~
=+ wal=^$(q.ham i.p.q.ham)
?~ wal
$(p.q.ham t.p.q.ham)
wal
::
{$plot *}
=- ?~ tok
~
[~ %rose [[' ' ~] ['[' ~] [']' ~]] u.tok]
^= tok
|- ^- (unit (list tank))
?~ p.q.ham
~
?: ?=({* ~} p.q.ham)
=+ wal=^$(q.ham i.p.q.ham)
?~(wal ~ [~ [u.wal ~]])
?@ lum
~
=+ gim=^$(q.ham i.p.q.ham, lum -.lum)
?~ gim
~
=+ myd=$(p.q.ham t.p.q.ham, lum +.lum)
?~ myd
~
[~ u.gim u.myd]
::
{$pear *}
?. =(lum q.q.ham)
~
=. p.q.ham
(rash p.q.ham ;~(sfix (cook crip (star low)) (star hig)))
=+ fox=$(q.ham [%mato p.q.ham])
?> ?=({~ $leaf ^} fox)
?: ?=(?($n $tas) p.q.ham)
fox
[~ %leaf '%' p.u.fox]
::
{$stop *}
?: (~(has in gil) [p.q.ham lum]) ~
=+ kep=(~(get by p.ham) p.q.ham)
?~ kep
~|([%stop-loss p.q.ham] !!)
$(gil (~(put in gil) [p.q.ham lum]), q.ham u.kep)
::
{$tree *}
=- ?~ tok
~
[~ %rose [[' ' ~] ['{' ~] ['}' ~]] u.tok]
^= tok
=+ tuk=*(list tank)
|- ^- (unit (list tank))
?: =(~ lum)
[~ tuk]
?. ?=({n/* l/* r/*} lum)
~
=+ rol=$(lum r.lum)
?~ rol
~
=+ tim=^$(q.ham q.q.ham, lum n.lum)
?~ tim
~
$(lum l.lum, tuk [u.tim u.rol])
::
{$unit *}
?@ lum
?.(=(~ lum) ~ [~ %leaf '~' ~])
?. =(~ -.lum)
~
=+ wal=$(q.ham q.q.ham, lum +.lum)
?~ wal
~
[~ %rose [[' ' ~] ['[' ~] [']' ~]] [%leaf '~' ~] u.wal ~]
==
::
++ doge
|= ham/cape
=- ?+ woz woz
{$list * {$mato $'ta'}} %path
{$list * {$mato $'t'}} %wall
{$list * {$mato $'tD'}} %yarn
{$list * $yarn} %wool
==
^= woz
^- wine
?. ?=({$stop *} q.ham)
?: ?& ?= {$bcwt {$pear $n $0} {$plot {$pear $n $0} {$face *} ~} ~}
q.ham
=(1 (met 3 p.i.t.p.i.t.p.q.ham))
==
[%unit =<([p q] i.t.p.i.t.p.q.ham)]
q.ham
=+ may=(~(get by p.ham) p.q.ham)
?~ may
q.ham
=+ nul=[%pear %n 0]
?. ?& ?=({$bcwt *} u.may)
?=({* * ~} p.u.may)
|(=(nul i.p.u.may) =(nul i.t.p.u.may))
==
q.ham
=+ din=?:(=(nul i.p.u.may) i.t.p.u.may i.p.u.may)
?: ?& ?=({$plot {$face *} {$face * $stop *} ~} din)
=(p.q.ham p.q.i.t.p.din)
=(1 (met 3 p.i.p.din))
=(1 (met 3 p.i.t.p.din))
==
:+ %list
(cat 3 p.i.p.din p.i.t.p.din)
q.i.p.din
?: ?& ?= $: $plot
{$face *}
{$face * $stop *}
{{$face * $stop *} ~}
==
din
=(p.q.ham p.q.i.t.p.din)
=(p.q.ham p.q.i.t.t.p.din)
=(1 (met 3 p.i.p.din))
=(1 (met 3 p.i.t.p.din))
=(1 (met 3 p.i.t.t.p.din))
==
:+ %tree
%^ cat
3
p.i.p.din
(cat 3 p.i.t.p.din p.i.t.t.p.din)
q.i.p.din
q.ham
::
++ dole
^- cape
=+ gil=*(set type)
=+ dex=[p=*(map type @) q=*(map @ wine)]
=< [q.p q]
|- ^- {p/{p/(map type @) q/(map @ wine)} q/wine}
=- [p.tez (doge q.p.tez q.tez)]
^= tez
^- {p/{p/(map type @) q/(map @ wine)} q/wine}
?: (~(meet ut sut) -:!>(*type))
[dex %type]
?- sut
$noun [dex sut]
$void [dex sut]
{$atom *} [dex ?~(q.sut [%mato p.sut] [%pear p.sut u.q.sut])]
{$cell *}
=+ hin=$(sut p.sut)
=+ yon=$(dex p.hin, sut q.sut)
:- p.yon
:- %plot
?:(?=({$plot *} q.yon) [q.hin p.q.yon] [q.hin q.yon ~])
::
{$core *}
=+ yad=$(sut p.sut)
:- p.yad
=+ ^= doy ^- {p/(list @ta) q/wine}
?: ?=({$core *} q.yad)
[p.q.yad q.q.yad]
[~ q.yad]
:- %core
:_ q.doy
:_ p.doy
%^ cat 3
%~ rent co
:+ %$ %ud
%- ~(rep by (~(run by q.s.q.sut) |=(tomb ~(wyt by q))))
|=([[@ a=@u] b=@u] (add a b))
==
%^ cat 3
?-(p.q.sut $gold '.', $iron '|', $lead '?', $zinc '&')
=+ gum=(mug q.s.q.sut)
%+ can 3
:~ [1 (add 'a' (mod gum 26))]
[1 (add 'a' (mod (div gum 26) 26))]
[1 (add 'a' (mod (div gum 676) 26))]
==
::
{$help *}
$(sut q.sut)
::
{$face *}
=+ yad=$(sut q.sut)
?^(q.p.sut yad [p.yad [%face q.p.sut q.yad]])
::
{$fork *}
=+ yed=~(tap in p.sut)
=- [p [%bcwt q]]
|- ^- {p/{p/(map type @) q/(map @ wine)} q/(list wine)}
?~ yed
[dex ~]
=+ mor=$(yed t.yed)
=+ dis=^$(dex p.mor, sut i.yed)
[p.dis q.dis q.mor]
::
{$hold *}
=+ hey=(~(get by p.dex) sut)
?^ hey
[dex [%stop u.hey]]
?: (~(has in gil) sut)
=+ dyr=+(~(wyt by p.dex))
[[(~(put by p.dex) sut dyr) q.dex] [%stop dyr]]
=+ rom=$(gil (~(put in gil) sut), sut ~(repo ut sut))
=+ rey=(~(get by p.p.rom) sut)
?~ rey
rom
[[p.p.rom (~(put by q.p.rom) u.rey q.rom)] [%stop u.rey]]
==
::
++ duck (dial dole)
--

View File

@ -1,366 +0,0 @@
::
::::
::
:- %say
|= {^ {{typ/type gen/hoon ~} ~}}
=< :- %noun
=+ pro=(~(mint ut typ) %noun gen)
~_ (~(dunk ut typ) 'blow-subject')
=+ bus=(bran:musk typ)
~& [%subject-mask mask.bus]
=+ jon=(apex:musk bus q.pro)
?~ jon
~& %constant-stopped
!!
?. ?=(%& -.u.jon)
~& %constant-blocked
!!
:: [p.pro [%1 p.u.jon]]
p.u.jon
|%
++ musk :: nock with block set
=> |%
++ block
:: identity of resource awaited
:: XX parameterize
noun
::
++ result
:: internal interpreter result
::
$@(~ seminoun)
::
++ seminoun
:: partial noun; blocked subtrees are ~
::
{mask/stencil data/noun}
::
++ stencil
:: noun knowledge map
::
$% :: no; noun has partial block substructure
::
{%| left/stencil rite/stencil}
:: yes; noun is either fully complete, or fully blocked
::
{%& blocks/(set block)}
==
::
++ output
:: nil; interpreter stopped
::
%- unit
:: yes, complete noun; no, list of blocks
::
(each noun (list block))
--
|%
++ bran
|= sut/type
=+ gil=*(set type)
|- ^- seminoun
?- sut
$noun [&+[~ ~ ~] ~]
$void [&+[~ ~ ~] ~]
{$atom *} ?~(q.sut [&+[~ ~ ~] ~] [&+~ u.q.sut])
{$cell *} (combine $(sut p.sut) $(sut q.sut))
{$core *} %+ combine:musk
?~ p.s.q.sut [&+[~ ~ ~] ~]
[&+~ p.s.q.sut]
$(sut p.sut)
{$face *} $(sut ~(repo ut sut))
{$fork *} [&+[~ ~ ~] ~]
{$help *} $(sut ~(repo ut sut))
{$hold *} ?: (~(has in gil) sut)
[&+[~ ~ ~] ~]
$(sut ~(repo ut sut), gil (~(put in gil) sut))
==
++ abet
:: simplify raw result
::
|= $: :: noy: raw result
::
noy/result
==
^- output
:: propagate stop
::
?~ noy ~
:- ~
:: merge all blocking sets
::
=/ blocks (squash mask.noy)
?: =(~ blocks)
:: no blocks, data is complete
::
&+data.noy
:: reduce block set to block list
::
|+~(tap in blocks)
::
++ apex
:: execute nock on partial subject
::
|= $: :: bus: subject, a partial noun
:: fol: formula, a complete noun
::
bus/seminoun
fol/noun
==
^- output
:: simplify result
::
%- abet
:: interpreter loop
::
|- ^- result
:: ~& [%apex-fol fol]
:: ~& [%apex-mac mask.bus]
:: =- ~& [%apex-pro-mac ?@(foo ~ ~!(foo mask.foo))]
:: foo
:: ^= foo
:: ^- result
?@ fol
:: bad formula, stop
::
~
?: ?=(^ -.fol)
:: hed: interpret head
::
=+ hed=$(fol -.fol)
:: propagate stop
::
?~ hed ~
:: tal: interpret tail
::
=+ tal=$(fol +.fol)
:: propagate stop
::
?~ tal ~
:: combine
::
(combine hed tal)
?+ fol
:: bad formula; stop
::
~
:: 0; fragment
::
{$0 b/@}
:: if bad axis, stop
::
?: =(0 b.fol) ~
:: reduce to fragment
::
(fragment b.fol bus)
::
:: 1; constant
::
{$1 b/*}
:: constant is complete
::
[&+~ b.fol]
::
:: 2; recursion
::
{$2 b/* c/*}
:: require complete formula
::
%+ require
:: compute formula with current subject
::
$(fol c.fol)
|= :: ryf: next formula
::
ryf/noun
:: lub: next subject
::
=+ lub=^$(fol b.fol)
:: propagate stop
::
?~ lub ~
:: recurse
::
^$(fol ryf, bus lub)
::
:: 3; probe
::
{$3 b/*}
%+ require
$(fol b.fol)
|= :: fig: probe input
::
fig/noun
:: yes if cell, no if atom
::
[&+~ .?(fig)]
::
:: 4; increment
::
{$4 b/*}
%+ require
$(fol b.fol)
|= :: fig: increment input
::
fig/noun
:: stop for cells, increment for atoms
::
?^(fig ~ [&+~ +(fig)])
::
:: 5; compare
::
{$5 b/*}
%+ require
$(fol b.fol)
|= :: fig: operator input
::
fig/noun
:: stop for atoms, compare cells
::
?@(fig ~ [&+~ =(-.fig +.fig)])
::
:: 6; if-then-else
::
{$6 b/* c/* d/*}
:: use standard macro expansion (slow)
::
$(fol =>(fol [2 [0 1] 2 [1 c d] [1 0] 2 [1 2 3] [1 0] 4 4 b]))
::
:: 7; composition
::
{$7 b/* c/*}
:: use standard macro expansion (slow)
::
$(fol =>(fol [2 b 1 c]))
::
:: 8; declaration
::
{$8 b/* c/*}
:: use standard macro expansion (slow)
::
$(fol =>(fol [7 [[7 [0 1] b] 0 1] c]))
::
:: 9; invocation
::
{$9 b/* c/*}
:: use standard macro expansion (slow)
::
$(fol =>(fol [7 c 2 [0 1] 0 b]))
::
:: 10; static hint
::
{$10 @ c/*}
:: ignore hint
::
$(fol c.fol)
::
:: 10; dynamic hint
::
{$10 {b/* c/*} d/*}
:: noy: dynamic hint
::
=+ noy=$(fol c.fol)
:: propagate stop
::
?~ noy ~
:: otherwise, ignore hint
::
$(fol d.fol)
==
::
++ combine
:: combine a pair of seminouns
::
|= $: :: hed: head of pair
:: tal: tail of pair
::
hed/seminoun
tal/seminoun
==
^- seminoun
?. ?& &(?=(%& -.mask.hed) ?=(%& -.mask.tal))
=(=(~ blocks.mask.hed) =(~ blocks.mask.tal))
==
:: default merge
::
[|+[mask.hed mask.tal] [data.hed data.tal]]
:: both sides total
::
?: =(~ blocks.mask.hed)
:: both sides are complete
::
[&+~ data.hed data.tal]
:: both sides are blocked
::
[&+(~(uni in blocks.mask.hed) blocks.mask.tal) ~]
::
++ fragment
:: seek to an axis in a seminoun
::
|= $: :: axe: tree address of subtree
:: bus: partial noun
::
axe/axis
bus/seminoun
==
|- ^- result
:: 1 is the root
::
?: =(1 axe) bus
:: now: 2 or 3, top of axis
:: lat: rest of axis
::
=+ [now=(cap axe) lat=(mas axe)]
?- -.mask.bus
:: subject is fully blocked or complete
::
%& :: if fully blocked, produce self
::
?^ blocks.mask.bus bus
:: descending into atom, stop
::
?@ data.bus ~
:: descend into complete cell
::
$(axe lat, bus [&+~ ?:(=(2 now) -.data.bus +.data.bus)])
:: subject is partly blocked
::
%| :: descend into partial cell
::
%= $
axe lat
bus ?: =(2 now)
[left.mask.bus -.data.bus]
[rite.mask.bus +.data.bus]
== ==
:: require complete intermediate step
::
++ require
|= $: noy/result
yen/$-(noun result)
==
^- result
:: propagate stop
::
?~ noy ~
:: if partial block, squash blocks and stop
::
?: ?=(%| -.mask.noy) [&+(squash mask.noy) ~]
:: if full block, propagate block
::
?: ?=(^ blocks.mask.noy) [mask.noy ~]
:: otherwise use complete noun
::
(yen data.noy)
::
++ squash
:: convert stencil to block set
::
|= tyn/stencil
^- (set block)
?- -.tyn
%& blocks.tyn
%| (~(uni in $(tyn left.tyn)) $(tyn rite.tyn))
==
--
--

View File

@ -1,194 +0,0 @@
/? 310
::
/+ pprint
::
!:
::
:- %say
::
=< |= {^ {{=arg ~} ~}}
^- [%txt wain]
::
=/ v=vase
?- target.arg
^ target.arg
%all !>(all-examples)
%demo !>(demo-example)
%test !>(test-example)
%type !>(type-example)
%xml !>(xml-example)
%kernel !>(xray-the-kernel-example)
%parser !>(xray-the-parser-example)
==
::
:- %txt
?- print.arg
%type (render-type:pprint p.v)
%val (render-vase:pprint v)
%both (render-vase-with-type:pprint v)
==
::
|%
::
+$ arg
$: print=?(%type %val %both)
target=$@(?(%all %demo %test %type %xml %kernel %parser) vase)
==
::
+$ option $?(%a %b %c)
::
+$ junct $@(@ {@ cord})
::
+$ union $%([%list (list ~)] [%unit (unit ~)])
::
+$ conjunct $^ [[@ @] cord]
[@ cord]
::
+$ misjunct $^([~ @] [cord @])
::
++ forks-example
:* :- %junct ^- (list junct) ~[3 [4 '5']]
:- %conjunct ^- (list conjunct) ~[[3 '4'] [[5 6] '7']]
:- %union ^- (list union) ~[[%list [~ ~]] [%unit [~ ~]]]
:- %option ^- (list option) ~[%a %a %b %c]
:- %misjunct ^- (list misjunct) ~[[~ 3] [~ 4]]
%nice
==
::
++ all-examples
:*
:- %type type-example
:- %cores core-example
:- %add ..add
:- zuse-example
:- %demo demo-example
:- %forks forks-example
%eof
==
::
++ type-example
^- type
-:!>(`(map ? (unit (list cord)))`~)
::
++ xray-the-parser-example
=> ..musk
|% ++ x ~ --
::
++ xray-the-kernel-example
|% ++ x ~ --
::
++ zuse-example
[%zuse ..zuse]
::
++ cores-example
|^ :*
[%trivial trivial-core-example]
[%gate gate-example]
[%core core-example]
==
::
--
::
++ trivial-core-example
=> ~
|% ++ x 3 --
::
++ core-example
=> [=gate-example]
|%
++ dup gate-example
++ const
|= x=* ^- $-(* *)
|= * ^- *
x
--
::
++ gate-example
=> ~
|= x=@ud
^- [@ud @ud]
[x x]
::
++ test-example
:*
`(list ?)`~[%.y %.n]
`(list ~)`~[~ ~]
`(unit ~)``~
/a/path
==
::
++ hoon-example
^- hoon
:+ %brcn ~
%- ~(gas by *(map term tome))
^- (list (pair term tome))
:_ ~
^- (pair term tome)
:- 'chapter'
^- tome
:- `what`~
%- ~(gas by *(map term hoon))
^- (list (pair term hoon))
:_ ~
:- 'arm'
:+ %brts `spec`[%bsts 'x' [%base [%atom ~.ud]]]
:- %clsg
~[[%wing ~['x']] [%$ 0]]
::
++ demo-example
:* [~ %.y %.n 1 0x2 ~ ~.knot 'cord' %const]
:* [%tape "a tape"]
[%path /path/literal `path`/typed/path]
[%unit `(unit @)`[~ 9]]
[%list [`?`%.y `(list ?)`~[%.y %.n %.y]]]
%nice
==
[%hoon hoon-example]
[%type -:!>(`(unit (list tape))`~)]
[%json-and-xml json-example xml-example]
%cool
==
::
++ xml-example
|^ ^- manx
:- ['json' ~]
:~ (json-to-xml json-example)
==
++ json-to-xml
|= j=json
^- manx
?- j
~ [['nil' ~] ~]
[%a *] [['array' ~] (turn p.j json-to-xml)]
[%b *] [['bool' ~[['' ?:(p.j "true" "false")]]] ~]
[%o *] [['obj' ~] (turn ~(tap by p.j) pair)]
[%n *] [['num' ~[[['n' 'val'] (trip p.j)]]] ~]
[%s *] [['str' ~[['' (trip p.j)]]] ~]
==
++ pair
|= [t=@t j=json]
^- manx
[['slot' ~[['key' (trip t)]]] ~[(json-to-xml j)]]
--
::
++ json-example
^- json
|^ ob2
++ nil ~
++ yes [%b %.y]
++ nah [%b %.n]
++ str [%s 'Very long test string. Test test test test test test test.']
++ foo 'foo'
++ bar 'bar'
++ baz 'baz'
++ one [%n '1']
++ ten [%n '10']
++ mil [%n '100000']
++ arr [%a ~[one ten mil]]
++ ar2 [%a ~[arr yes nah nil str]]
++ obj [%o (~(gas by *(map @t json)) ~[[foo mil] [baz arr]])]
++ ob2 [%o (~(gas by *(map @t json)) ~[[foo ar2] [bar obj] [baz yes]])]
++ ar3 [%a ~[arr obj ob2 one ten mil yes nah nil]]
--
::
--