++mack
Nock subject to unit
Accepts a nock subject-formula cell and wraps it into a ++unit
.
fol
is pure nock, meaning that nock 11
operations result in a block,
producing a ~
.
Accepts
sub
is a subject noun.
fol
is a formula noun, which is generally a ++nock
.
Produces
The ++unit
of a noun.
Source
++ mack
|= {sub/* fol/*}
^- (unit)
=+ ton=(mink [sub fol] |=({* *} ~))
?.(?=({$0 *} ton) ~ [~ p.ton])
::
Examples
> (mack [[1 2 3] [0 1]])
[~ [1 2 3]]
> (mack [41 4 0 1])
[~ 42]
> (mack [4 0 4])
~
> (mack [[[0 2] [1 3]] 4 4 4 4 0 5])
[~ 6]
> ;;((unit @tas) (mack [[1 %yes %no] 6 [0 2] [0 6] 0 7]))
[~ %no]
++mink
Mock interpreter
Bottom-level mock (virtual nock) interpreter. Produces a
++tone
, a nock computation result. If nock 11 is invoked, sky
computes on the subject and produces a ++unit
result. An empty
result becomes a %1
++tone
, indicating a block.
Accepts
sub
is the subject as a noun.
fol
is the formula as a noun.
sky
is an %iron
gate invoked with nock operator 11.
Produces
A ++tone
.
Source
++ mink
~/ %mink
|= {{sub/* fol/*} gul/$-({* *} (unit (unit)))}
=+ tax=*(list {@ta *})
|- ^- tone
?@ fol
[%2 tax]
?: ?=(^ -.fol)
=+ hed=$(fol -.fol)
?: ?=($2 -.hed)
hed
=+ tal=$(fol +.fol)
?- -.tal
$0 ?-(-.hed $0 [%0 p.hed p.tal], $1 hed)
$1 ?-(-.hed $0 tal, $1 [%1 (weld p.hed p.tal)])
$2 tal
==
?+ fol
[%2 tax]
::
{$0 b/@}
?: =(0 b.fol) [%2 tax]
?: =(1 b.fol) [%0 sub]
?: ?=(@ sub) [%2 tax]
=+ [now=(cap b.fol) lat=(mas b.fol)]
$(b.fol lat, sub ?:(=(2 now) -.sub +.sub))
::
{$1 b/*}
[%0 b.fol]
::
{$2 b/{^ *}}
=+ ben=$(fol b.fol)
?. ?=($0 -.ben) ben
?>(?=(^ p.ben) $(sub -.p.ben, fol +.p.ben))
::?>(?=(^ p.ben) $([sub fol] p.ben)
::
{$3 b/*}
=+ ben=$(fol b.fol)
?. ?=($0 -.ben) ben
[%0 .?(p.ben)]
::
{$4 b/*}
=+ ben=$(fol b.fol)
?. ?=($0 -.ben) ben
?. ?=(@ p.ben) [%2 tax]
[%0 .+(p.ben)]
::
{$5 b/*}
=+ ben=$(fol b.fol)
?. ?=($0 -.ben) ben
?. ?=(^ p.ben) [%2 tax]
[%0 =(-.p.ben +.p.ben)]
::
{$6 b/* c/* d/*}
$(fol =>(fol [2 [0 1] 2 [1 c d] [1 0] 2 [1 2 3] [1 0] 4 4 b]))
::
{$7 b/* c/*} $(fol =>(fol [2 b 1 c]))
{$8 b/* c/*} $(fol =>(fol [7 [[0 1] b] c]))
{$9 b/* c/*} $(fol =>(fol [7 c 0 b]))
{$10 @ c/*} $(fol c.fol)
{$10 {b/* c/*} d/*}
=+ ben=$(fol c.fol)
?. ?=($0 -.ben) ben
?: ?=(?($hunk $hand $lose $mean $spot) b.fol)
$(fol d.fol, tax [[b.fol p.ben] tax])
$(fol d.fol)
::
{$11 b/* c/*}
=+ ref=$(fol b.fol)
=+ ben=$(fol c.fol)
?. ?=($0 -.ref) ref
?. ?=($0 -.ben) ben
=+ val=(gul p.ref p.ben)
?~(val [%1 p.ben ~] ?~(u.val [%2 [[%hunk (mush p.ben)] tax]] [%0 u.u.val]))
==
::
Examples
> (mink [20 [4 0 1]] $~)
[%0 p=21]
> (mink [[90 5 3] [0 3]] $~)
[%0 p=[5 3]]
> (mink 20^[4 0 1] $~)
[%0 p=21]
> (mink [90 5 3]^[0 3] $~)
[%0 p=[5 3]]
> (mink [0]^[11 1 20] $~)
[%1 p=~[20]]
> (mink [0]^[11 1 20] |=(a=* `[40 a]))
[%0 p=[40 20]]
> (mink [5]^[0 2] $~)
[%2 p=~]
> (mink [5]^[10 yelp/[0 1] 0 0] $~)
[%2 p=~[[~.yelp 5]]]
++mock
Compute formula on subject with hint
Produces a ++toon
, which is either a sucessful, blocked, or
crashed result. If nock 11 is invoked, sky
computes on the subject and
produces a ++unit
result. An empty result becomes a %1
++tune
,
indicating a block.
Accepts
sub
is the subject as a noun.
fol
is the formula as a noun.
sky
is an %iron gate invoked with nock operator 11.
Produces
The ++unit
of a noun.
Source
++ mock
|= {{sub/* fol/*} gul/$-({* *} (unit (unit)))}
(mook (mink [sub fol] gul))
::
Examples
> (mock [5 4 0 1] ,~)
[%0 p=6]
> (mock [~ 11 1 0] |=(* `999))
[%0 p=999]
> (mock [~ 0 1.337] ,~)
[%2 p=~]
> (mock [~ 11 1 1.337] ,~)
[%1 p=~[1.337]]
> (mock [[[4 4 4 4 0 3] 10] 11 9 2 0 1] |=(* `[+<]))
[%0 p=14]
> (mock [[[4 4 4 4 0 3] 10] 11 9 2 0 1] |=(* `[<+<>]))
[%0 p=[49 52 0]]
> ;;(tape +:(mock [[[4 4 4 4 0 3] 10] 11 9 2 0 1] |=(* `[<+<>])))
"14"
++mong
Slam gate with sample
Produces a ++toon
computation result from slamming gat
with
sam
, using sky
to compute or block on nock 11 when applicable.
Accepts
gat
is a noun that is generally a gate
.
sam
is a sample
noun.
sky
is an %iron gate invoked with nock operator 11.
Produces
A ++toon
.
Source
++ mong
|= {{gat/* sam/*} gul/$-({* *} (unit (unit)))}
^- toon
?. &(?=(^ gat) ?=(^ +.gat))
[%2 ~]
(mock [[-.gat [sam +>.gat]] -.gat] gul)
::
Examples
> (mong [|=(@ 20) ~] ,~)
[%0 p=20]
> (mong [|=(@ !!) ~] ,~)
[%2 p=~]
> (mong [|=(a/@ (add 20 a)) ~] ,~)
[%0 p=20]
> (mong [|=(a/[@ @] (add 20 -.a)) ~] ,~)
[%2 p=~]
> (mong [|=(a/[@ @] (add 20 -.a)) [4 6]] ,~)
[%0 p=24]
> (mong [|=(a/@ .^(a)) ~] ,~)
[%1 p=~[0]]
> (mong [|=(a/@ .^(a)) ~] ,[~ %42])
[%0 p=42]
> (mong [|=(a/@ .^(a)) ~] |=(a/* [~ a 6]))
[%0 p=[0 6]]
> (mong [|=(a/@ .^(a)) 8] |=(a/* [~ a 6]))
[%0 p=[8 6]]
++mook
Intelligently render crash annotation
Converts a %2
++tone
nock stack trace to a list of ++tank
.
Each may be a tank, cord, ++spot
, or trapped tank.
Accepts
ton
is a ++tone
.
Produces
A ++toon
.
Source
++ mook
|= ton/tone
^- toon
?. ?=({$2 *} ton) ton
:- %2
:: =. p.ton (moop p.ton)
=+ yel=(lent p.ton)
=. p.ton
?. (gth yel 256) p.ton
%+ weld
(scag 128 p.ton)
^- (list {@ta *})
:_ (slag (sub yel 128) p.ton)
:- %lose
%+ rap 3
"[skipped {(scow %ud (sub yel 256))} frames]"
|- ^- (list tank)
?~ p.ton ~
=+ rep=$(p.ton t.p.ton)
?+ -.i.p.ton rep
$hunk [(tank +.i.p.ton) rep]
$lose [[%leaf (rip 3 (@ +.i.p.ton))] rep]
$hand [[%leaf (scow %p (mug +.i.p.ton))] rep]
$mean :_ rep
?@ +.i.p.ton [%leaf (rip 3 (@ +.i.p.ton))]
=+ mac=(mack +.i.p.ton +<.i.p.ton)
?~(mac [%leaf "####"] (tank u.mac))
$spot :_ rep
=+ sot=(spot +.i.p.ton)
:+ %rose [":" ~ ~]
:~ (smyt p.sot)
=> [ud=|=(a/@u (scow %ud a)) q.sot]
leaf+"<[{(ud p.p)} {(ud q.p)}].[{(ud p.q)} {(ud q.q)}]>"
== ==
::
Examples
> (mook [%0 5 4 5 1])
[%0 p=[5 4 5 1]]
> (mook [%2 ~[[%hunk %rose ["<" "," ">"] ~[[%leaf "err"]]]]])
[%2 p=~[[%rose p=[p="<" q="," r=">"] q=[i=[%leaf p="err"] t=~]]]]
> (mook [%2 ~[[%malformed %elem] [%lose 'do print']]])
[%2 p=~[[%leaf p="do print"]]]
> (mook [%2 ~[[%mean |.(>(add 5 6)<)]]])
[%2 p=~[[%leaf p="11"]]]
> (mook [%2 ~[[%spot /b/repl [1 1]^[1 2]] [%mean |.(!!)]]])
[%2 p=~[[%leaf p="/b/repl/:<[1 1].[1 2]>"] [%leaf p="####"]]]
++mule
Typed virtual
Kicks a ++trap
, producing its results or any errors that occur along
the way. Used to lazily compute stack traces.
Accepts
taq
is a ++trap
, generally producing a list of ++tank
s.
Produces
XX
Source
++ mule :: typed virtual
~/ %mule
|* taq/_|.(**)
=+ mud=(mute taq)
?- -.mud
$& [%& p=$:taq] :: XX transition
$| [%| p=p.mud]
==
::
Examples
> (mule |.(leaf/"hello"))
[%.y p=[%leaf "hello"]]
> (mule |.(!!))
[%.n p=~]
> (mule |.(.^(a//=pals/1)))
[ %.n
p
~[
[ %rose
p=[p="/" q="/" r="/"]
q
[ i=[%leaf p="a"]
t=[i=[%leaf p="~zod"] t=[i=[%leaf p="pals"] t=[i=[%leaf p="1"] t=~]]]
]
]
]
]
++mute
Untyped virtual
Kicks a ++trap
, producing its result as a noun or the tanks of any
error that occurs. Similar to ++mule
, but preserves no type
information.
Accepts
taq
is a ++trap
.
Produces
Either a noun or a ++list
of ++tank
.
Source
++ mute :: untyped virtual
|= taq/_^?(|.(**))
^- (each * (list tank))
=+ ton=(mock [taq 9 2 0 1] |=({* *} ~))
?- -.ton
$0 [%& p.ton]
$1 [%| (turn p.ton |=(a/* (smyt (path a))))]
$2 [%| p.ton]
==
Examples
> (mute |.(leaf/"hello"))
[%.y p=[1.717.658.988 104 101 108 108 111 0]]
> (mute |.(!!))
[%.n p=~]