Merge remote-tracking branch 'origin/shell' into dish

Conflicts:
	urb/urbit.pill
	urb/zod/arvo/hoon.hoon
	urb/zod/main/app/terminal/hymn/script.js
This commit is contained in:
Philip C Monk 2014-10-30 16:48:18 -04:00
commit 5d40a20598
6 changed files with 632 additions and 701 deletions

View File

@ -219,18 +219,16 @@
=+ jun=(ecci orx moh)
:: ~& [%ecca jun]
?~ jun ~
=+ ^- (unit ,[his=term app=term pax=term])
=+ ^- (unit ,[his=ship app=term pax=term])
%. u.jun
%- ot:jo
~[[%ship so:jo] [%appl so:jo] [%path so:jo]]
~[[%ship (su:jo fed:ag)] [%appl so:jo] [%path so:jo]]
?~ - ~
=+ his=(slaw %p (cat 3 '~' his.u))
?~ his ~
=+ ^= pax
%+ rush pax.u
;~(pfix fas (more fas (cook crip (plus ;~(pose low nud hep)))))
?~ pax ~
`[[u.his app.u] u.pax]
`[[his.u app.u] u.pax]
::
++ ecce :: JS from moth
|= moh=moth

View File

@ -132,7 +132,7 @@
$% [%lite p=char] :: literal
[%pair p=rege q=rege] :: ordering
[%capt p=rege q=@u] :: capture group
[%brac p=@] :: p is 256 bitmask
[%brac p=@I] :: p is 256 bitmask
[%eith p=rege q=rege] :: either
[%mant p=rege] :: greedy 0 or more
[%plls p=rege] :: greedy 1 or more
@ -619,6 +619,11 @@
|* [a=(unit) b=*]
?~(a b u.a)
::
++ flit :: make filter
|* a=_,?
|* b=*
?.((a b) ~ [~ u=b])
::
++ lift :: lift gate (fmap)
|* a=gate :: flipped
|* b=(unit) :: curried
@ -1643,7 +1648,7 @@
::
++ year :: date to @d
|= det=date
^- @d
^- @da
=+ ^= yer
?: a.det
(add 292.277.024.400 y.det)
@ -1652,7 +1657,7 @@
(yule day h.t.det m.t.det s.t.det f.t.det)
::
++ yore :: @d to date
|= now=@d
|= now=@da
^- date
=+ rip=(yell now)
=+ ger=(yall d.rip)
@ -2142,11 +2147,11 @@
=+ f=$(a r.a, b -.e)
[-.f [n.a +.e +.f]]
::
+- run :: turns to tuples
+- run :: apply gate to values
|* b=_,*
|-
?~ a a
[[p.n.a (b q.n.a)] $(a l.a) $(a r.a)]
[n=[p=p.n.a q=(b q.n.a)] l=$(a l.a) r=$(a r.a)]
::
+- tap :: listify pairs
~/ %tap
@ -2176,7 +2181,7 @@
$(b [n.b $(b l.b, a [n.a l.a ~]) r.b], a r.a)
$(b [n.b l.b $(b r.b, a [n.a ~ r.a])], a l.a)
::
+- urn :: turn
+- urn :: apply gate to nodes
|* b=$+([* *] *)
|-
?~ a ~
@ -2252,8 +2257,9 @@
:: section 2dD, casual containers ::
::
++ mo :: make a map
|* a=(list)
=> .(a `_(homo a)`a)
|* a=(pole ,^)
=> .(a ^.(|*(a=$|(~ ^) ?~(a ~ [i=-.a t=$(a +.a)])) a))
=> .(a ^.(homo a))
=> .(a `(list ,[p=_-<.a q=_->.a])`a)
=+ b=*(map ,_?>(?=(^ a) p.i.a) ,_?>(?=(^ a) q.i.a))
(~(gas by b) a)
@ -2720,39 +2726,39 @@
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: section 2eF, parsing (ascii) ::
::
++ ace (just ' ') :: spACE
++ bar (just '|') :: vertical BAR
++ bas (just '\\') :: Back Slash (escaped)
++ buc (just '$') :: dollars BUCks
++ cab (just '_') :: CABoose
++ cen (just '%') :: perCENt
++ col (just ':') :: COLon
++ com (just ',') :: COMma
++ doq (just '"') :: Double Quote
++ dot (just '.') :: dot dot dot ...
++ fas (just '/') :: Forward Slash
++ gal (just '<') :: Greater Left
++ gar (just '>') :: Greater Right
++ hax (just '#') :: Hash
++ kel (just '{') :: Curly Left
++ ker (just '}') :: Curly Right
++ ket (just '^') :: CareT
++ lus (just '+') :: pLUS
++ hep (just '-') :: HyPhen
++ pel (just '(') :: Paren Left
++ pam (just '&') :: AMPersand pampersand
++ per (just ')') :: Paren Right
++ pat (just '@') :: AT pat
++ sel (just '[') :: Square Left
++ sem (just ';') :: SEMicolon
++ ser (just ']') :: Square Right
++ sig (just '~') :: SIGnature squiggle
++ soq (just '\'') :: Single Quote
++ tar (just '*') :: sTAR
++ tec (just '`') :: backTiCk
++ tis (just '=') :: 'tis tis, it is
++ wut (just '?') :: wut, what?
++ zap (just '!') :: zap! bang! crash!!
++ ace (just ' ')
++ bar (just '|')
++ bas (just '\\')
++ buc (just '$')
++ cab (just '_')
++ cen (just '%')
++ col (just ':')
++ com (just ',')
++ doq (just '"')
++ dot (just '.')
++ fas (just '/')
++ gal (just '<')
++ gar (just '>')
++ hax (just '#')
++ kel (just '{')
++ ker (just '}')
++ ket (just '^')
++ lus (just '+')
++ hep (just '-')
++ pel (just '(')
++ pam (just '&')
++ per (just ')')
++ pat (just '@')
++ sel (just '[')
++ sem (just ';')
++ ser (just ']')
++ sig (just '~')
++ soq (just '\'')
++ tar (just '*')
++ tec (just '`')
++ tis (just '=')
++ wut (just '?')
++ zap (just '!')
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: section 2eG, parsing (whitespace) ::
::
@ -2898,8 +2904,7 @@
::
++ sand :: atom sanity
|= a=@ta
|= b=@ ^- (unit ,@)
?.(((sane a) b) ~ [~ b])
(flit (sane a))
::
++ sane :: atom sanity
|= a=@ta
@ -3226,14 +3231,6 @@
++ sew ;~(pose sed sow)
++ sex ;~(pose sed sox)
++ sib (cook |=(a=@ (sub a '0')) (shim '0' '1'))
++ siq ;~ pose
(shim 'a' 'z')
(shim 'A' 'Z')
(shim '0' '9')
hep
(cold 32 dot)
;~(pfix sig ;~(pose sig dot bix))
==
++ sid (cook |=(a=@ (sub a '0')) (shim '0' '9'))
++ siv ;~(pose sid sov)
++ siw ;~(pose sid sow)
@ -3277,7 +3274,6 @@
++ hex (ape (bass 0x1.0000 ;~(plug qex:ab (star ;~(pfix dog qix:ab)))))
++ lip =+ tod=(ape ted:ab)
(bass 256 ;~(plug tod (stun [3 3] ;~(pfix dog tod))))
++ tyq (cook |=(a=(list ,@) (rap 3 a)) (plus siq:ab))
++ viz (ape (bass 0x200.0000 ;~(plug pev:ab (star ;~(pfix dog piv:ab)))))
++ vum (bass 32 (plus siv:ab))
++ wiz (ape (bass 0x4000.0000 ;~(plug pew:ab (star ;~(pfix dog piw:ab)))))
@ -3657,45 +3653,45 @@
~
[~ p.u.q.vex]
::
++ smyt
++ smyt :: pretty print path
|= bon=path ^- tank
:+ %rose [['/' ~] ['/' ~] ['/' ~]]
|- ^- (list tank)
(turn bon |=(a=@ [%leaf (rip 3 a)]))
(turn bon |=(a=@ [%leaf (trip a)]))
::
++ spat |=(pax=path (crip (spud pax))) :: render path to cord
++ spud :: render path to tape
|= pax=path ^- tape
=- ~(ram re %rose ["/" "/" ~] -)
(turn pax |=(a=span [%leaf (trip a)]))
++ stab :: parse span to path
|= zep=@ta ^- path
(rash zep ;~(pfix fas (more fas urs:ab)))
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: section 2eM, regular-expressions ::
::
++ pars
|= [a=tape] :: parse tape to rege
^- (unit rege)
=+ foo=((full anns) [[1 1] a])
=+ foo=((full apex:rags) [[1 1] a])
?~ q.foo
~
[~ p.u.q.foo]
::
++ nor
;~ pose
(shim 1 35)
(shim 37 39)
(shim 44 45)
(shim 47 62)
(shim 64 90)
(shim 93 93)
(shim 95 122)
(shim 123 123)
(shim 125 127)
==
++ les ;~(pose (shim 32 91) (shim 93 126))
++ lep ;~(pose (shim 32 45) (shim 46 90) (shim 95 126))
++ alm (shim 32 126)
++ alb ;~(pose (shim 32 92) (shim 94 126))
++ mis ;~(pose (shim 32 47) (shim 58 64) (shim 91 96) (shim 123 126))
::
++ anns :: top level rege parse
++ rags :: rege parsers
=> |%
++ nor ;~(less (mask "^$()|*?+.[\\") (shim 1 127)) :: non-control char
++ les ;~(less bas asp) :: not backslash
++ lep ;~(less (mask "-^[]\\") asp) :: charset non-control
++ asp (shim 32 126) :: printable ascii
++ alb ;~(less ser asp) :: charset literal char
++ mis ;~(less aln asp) :: non alphanumeric
--
|%
++ apex :: top level
%+ knee *rege |. ~+
;~ pose
;~((bend |=(a=[rege rege] (some [%eith a]))) mall ;~(pfix bar anns))
(stag %eith ;~(plug (easy %empt) ;~(pfix bar anns)))
;~((bend |=(a=[rege rege] (some [%eith a]))) mall ;~(pfix bar apex))
(stag %eith ;~(plug (easy %empt) ;~(pfix bar apex)))
(easy %empt)
==
::
@ -3750,10 +3746,10 @@
=+ foo=;~(plug kel dim:ag ;~(pose ker (jest ',}') ;~(plug com dim:ag ker)))
=+ bar=(foo tub)
?~(q.bar (chad tub) (fail tub))
(cook |=([a=rege] [%capt a 0]) (ifix [pel per] anns))
(cook |=([a=rege] [%capt a 0]) (ifix [pel per] apex))
%+ cook |=([a=rege] [%capt a 0])
(ifix [;~(plug (jest '(?P<') (plus aln) gar) per] anns)
(ifix [(jest '(?:') per] anns)
(ifix [;~(plug (jest '(?P<') (plus aln) gar) per] apex)
(ifix [(jest '(?:') per] apex)
(stag %brac ;~(pfix sel seac))
==
::
@ -3811,44 +3807,22 @@
%+ knee *@ |. ~+
;~ pose
unid
(cold lower (jest '[:lower:]'))
(cold upper (jest '[:upper:]'))
(cold digit (jest '[:digit:]'))
(cold print (jest '[:print:]'))
(cold graph (jest '[:graph:]'))
(cold blank (jest '[:blank:]'))
(cold space (jest '[:space:]'))
(cold cntrl (jest '[:cntrl:]'))
(cold alpha (jest '[:alpha:]'))
(cold xdigit (jest '[:xdigit:]'))
(cold alnum (jest '[:alnum:]'))
(cold punct (jest '[:punct:]'))
(cold (flap lower) (jest '[:^lower:]'))
(cold (flap upper) (jest '[:^upper:]'))
(cold (flap digit) (jest '[:^digit:]'))
(cold (flap print) (jest '[:^print:]'))
(cold (flap graph) (jest '[:^graph:]'))
(cold (flap blank) (jest '[:^blank:]'))
(cold (flap space) (jest '[:^space:]'))
(cold (flap cntrl) (jest '[:^cntrl:]'))
(cold (flap alpha) (jest '[:^alpha:]'))
(cold (flap xdigit) (jest '[:^xdigit:]'))
(cold (flap alnum) (jest '[:^alnum:]'))
(cold (flap punct) (jest '[:^punct:]'))
%+ ifix (jest '[:')^(jest ':]')
;~(pose ;~(pfix ket (cook flap chas)) chas)
%+ sear |=([a=@ b=@] ?:((gth a b) ~ (some (ranc a b))))
;~(plug alm ;~(pfix hep alb))
;~(plug asp ;~(pfix hep alb))
|= tub=nail
?~ q.tub
(fail tub)
?~ t.q.tub
((cook bex les) tub)
?: =(i.t.q.tub '-')
?. =(i.t.q.tub '-')
((cook bex les) tub)
?~ t.t.q.tub
((cook bex les) tub)
?: =(i.t.t.q.tub ']')
((cook bex les) tub)
(fail tub)
((cook bex les) tub)
;~(pfix bas escd)
==
::
@ -3860,25 +3834,33 @@
(cook |=(a=char (tape [a ~])) next)
(full (easy ~))
==
::
++ lower (ranc 'a' 'z')
++ upper (ranc 'A' 'Z')
++ digit (ranc '0' '9')
++ print (ranc 32 126)
++ graph (ranc 33 126)
++ blank (con (bex 32) (bex 9))
++ space :(con (ranc 9 13) (bex ' '))
++ cntrl :(con (ranc 0 31) (bex 127))
++ alpha :(con lower upper)
++ chas :: ascii character set
=- (sear ~(get by -) sym)
%- mo ^- (list ,[@tas @I])
:~ alnum/alnum alpha/alpha ascii/ascii blank/blank cntrl/cntrl
digit/digit graph/graph lower/lower print/print punct/punct
space/space upper/upper word/wordc xdigit/xdigit
==
:: Character sets
++ alnum :(con lower upper digit)
++ alpha :(con lower upper)
++ ascii (ranc 0 127)
++ blank (con (bex 32) (bex 9))
++ cntrl :(con (ranc 0 31) (bex 127))
++ digit (ranc '0' '9')
++ graph (ranc 33 126)
++ lower (ranc 'a' 'z')
++ print (ranc 32 126)
++ punct ;: con
(ranc '!' '/')
(ranc ':' '@')
(ranc '[' '`')
(ranc '{' '~')
==
++ wordc :(con digit lower upper (bex 95))
++ space :(con (ranc 9 13) (bex ' '))
++ upper (ranc 'A' 'Z')
++ white :(con (bex ' ') (ranc 9 10) (ranc 12 13))
++ wordc :(con digit lower upper (bex '_'))
++ xdigit :(con (ranc 'a' 'f') (ranc 'A' 'F') digit)
::
++ chad
@ -3886,86 +3868,66 @@
;~(pose (stag %lite nor) (stag %brac unid) ;~(pfix bas escp))
::
++ escd
%+ knee *@ |. ~+
%+ cook bex
;~ pose
(cold (bex 7) (just 'a'))
(cold (bex 9) (just 't'))
(cold (bex 10) (just 'n'))
(cold (bex 11) (just 'v'))
(cold (bex 12) (just 'f'))
(cold (bex 13) (just 'r'))
(cold (bex 0) (just '0'))
(sear |=(a=@ ?:((lth a 256) (some (bex a)) ~)) (bass 8 (stun [2 3] cit)))
(cook bex ;~(pfix (just 'x') (bass 16 (stun [2 2] hit))))
(cook bex (ifix [(jest 'x{') ker] (bass 16 (stun [2 2] hit))))
(cook bex mis)
(cold 0 (just '0'))
(sear ~(get by (mo a/7 t/9 n/10 v/11 f/12 r/13 ~)) low)
(sear |=(a=@ ?:((lth a 256) (some a) ~)) (bass 8 (stun [2 3] cit)))
;~(pfix (just 'x') (bass 16 (stun [2 2] hit)))
(ifix [(jest 'x{') ker] (bass 16 (stun [2 2] hit)))
mis
==
::
++ escp
%+ knee *rege |. ~+
;~ pose
(cold %empt (just 'Q'))
(cold [%lite `@tD`0] (just '0'))
(cold [%lite `@tD`7] (just 'a'))
(cold [%lite `@tD`9] (just 't'))
(cold [%lite `@tD`10] (just 'n'))
(cold [%lite `@tD`11] (just 'v'))
(cold [%lite `@tD`12] (just 'f'))
(cold [%lite `@tD`13] (just 'r'))
(sear |=(a=@ ?:((lth a 256) (some [%lite a]) ~)) (bass 8 (stun [2 3] cit)))
(stag %lite ;~(pfix (just 'x') (bass 16 (stun [2 2] hit))))
(stag %lite (ifix [(jest 'x{') ker] (bass 16 (stun [2 2] hit))))
(cold %dote (just 'C'))
(cold %sart (just 'A'))
(cold %ende (just 'z'))
(cold %boun (just 'b'))
(cold %bout (just 'B'))
(stag %brac (cold wordc (just 'w')))
(stag %brac (cold (flap wordc) (just 'W')))
(stag %lite mis)
(stag %lite escd)
(sear ~(get by (mo b/%boun w/[%brac wordc] z/%ende ~)) low)
=- (sear ~(get by (mo -)) hig)
~['A'^%sart 'B'^%bout 'C'^%dote 'Q'^%empt 'W'^[%brac (flap wordc)]]
==
::
++ unid
%+ knee *@ |. ~+
=+ cha=~(get by (mo d/digit s/white w/wordc ~))
;~ pfix bas
;~ pose
(cold digit (jest '\\d'))
(cold (flap digit) (jest '\\D'))
(cold white (jest '\\s'))
(cold (flap white) (jest '\\S'))
(cold wordc (jest '\\w'))
(cold (flap wordc) (jest '\\W'))
==
(sear cha low)
(cook flap (sear |=(a=@ (cha (add a 32))) hig))
== ==
--
::
++ ra :: regex engine
|_ a=rege
++ proc :: capture numbering
|= [a=rege b=@]
^- [@ rege]
|= b=@
=- -(+ +>.$(a a))
^- [p=@ a=rege]
?- a
[%capt *] =+ foo=$(a p.a, b +(b))
[-.foo [%capt +.foo b]]
[p.foo [%capt a.foo b]]
[%eith *] =+ foo=$(a p.a)
=+ bar=$(a q.a, b -.foo)
[-.bar [%eith +.foo +.bar]]
=+ bar=$(a q.a, b p.foo)
[p.bar [%eith a.foo a.bar]]
[%pair *] =+ foo=$(a p.a)
=+ bar=$(a q.a, b -.foo)
[-.bar [%pair +.foo +.bar]]
=+ bar=$(a q.a, b p.foo)
[p.bar [%pair a.foo a.bar]]
[%manl *] =+ foo=$(a p.a)
[-.foo [%manl +.foo]]
[p.foo [%manl a.foo]]
[%plll *] =+ foo=$(a p.a)
[-.foo [%plll +.foo]]
[p.foo [%plll a.foo]]
[%binl *] =+ foo=$(a p.a)
[-.foo [%binl +.foo q.a]]
[p.foo [%binl a.foo q.a]]
[%betl *] =+ foo=$(a p.a)
[-.foo [%betl +.foo q.a r.a]]
[p.foo [%betl a.foo q.a r.a]]
[%mant *] =+ foo=$(a p.a)
[-.foo [%mant +.foo]]
[p.foo [%mant a.foo]]
[%plls *] =+ foo=$(a p.a)
[-.foo [%plls +.foo]]
[p.foo [%plls a.foo]]
[%bant *] =+ foo=$(a p.a)
[-.foo [%bant +.foo q.a]]
[p.foo [%bant a.foo q.a]]
[%bint *] =+ foo=$(a p.a)
[-.foo [%bint +.foo q.a]]
[p.foo [%bint a.foo q.a]]
[%betw *] =+ foo=$(a p.a)
[-.foo [%betw +.foo q.a r.a]]
[p.foo [%betw a.foo q.a r.a]]
* [b a]
==
::
@ -3981,26 +3943,26 @@
[~ [[a -.u.b] +.u.b]]
::
++ matc
|= [a=rege b=tape c=tape]
|= [b=tape c=tape]
^- (unit (map ,@u tape))
=+ foo=`(unit ,[tape (map ,@u tape)])`(deep a b %empt c)
=+ foo=`(unit ,[tape (map ,@u tape)])`(deep b %empt c)
(bind foo |*(a=^ (~(put by +.a) 0 -.a)))
::
++ chet
|= [a=(unit ,[tape (map ,@u tape)]) b=rege c=tape d=tape]
|= [b=(unit ,[tape (map ,@u tape)]) c=tape d=tape]
^- (unit ,[tape (map ,@u tape)])
?~ a
a
=+ ft=u.a
?~ -.ft
a
=+ bar=(deep b (slag (lent -.ft) c) %empt d)
?~ b
b
?~ -.u.b
b
=+ bar=(deep (slag (lent -.u.b) c) %empt d)
?~ bar
bar
a
b
++ blak (some ["" _(map ,@u tape)])
++ word |=(a=char =((dis wordc:rags (bex a)) 0))
++ deep
|= [a=rege b=tape c=rege d=tape]
|= [b=tape c=rege d=tape]
^- (unit ,[tape (map ,@u tape)])
?- a
%dote ?~(b ~ (some [[i.b ~] _(map ,@u tape)]))
@ -4011,15 +3973,15 @@
?: =(b d)
&
=+ foo=(slag (dec (sub (lent d) (lent b))) d)
=((dis wordc (bex -.foo)) 0)
=+ cuc=?~(b & =((dis wordc (bex -.b)) 0))
(word -.foo)
=+ cuc=?~(b & (word -.b))
?:(!=(luc cuc) blak ~)
%bout =+ ^= luc
?: =(b d)
&
=+ foo=(slag (dec (sub (lent d) (lent b))) d)
=((dis wordc (bex -.foo)) 0)
=+ cuc=?~(b & =((dis wordc (bex -.b)) 0))
(word -.foo)
=+ cuc=?~(b & (word -.b))
?:(=(luc cuc) blak ~)
[%capt *] =+ foo=$(a p.a)
?~ foo
@ -4035,8 +3997,8 @@
?. =((dis (bex `@`i.b) p.a) 0)
(some [[i.b ~] _(map ,@u tape)])
~
[%eith *] =+ foo=(chet $(a p.a) c b d)
=+ bar=(chet $(a q.a) c b d)
[%eith *] =+ foo=(chet(a c) $(a p.a) b d)
=+ bar=(chet(a c) $(a q.a) b d)
?~ foo
bar
?~ bar
@ -4092,6 +4054,7 @@
$(a [%eith %empt [%pair p.a [%betl p.a 0 (dec r.a)]]])
$(a [%pair p.a [%betl p.a (dec q.a) (dec r.a)]])
==
--
::
++ rexp :: Regex match
~/ %rexp
@ -4107,15 +4070,15 @@
$(a (dec a))
=+ par=(pars a)
?~ par ~
=+ poc=(proc u.par 1)
=+ poc=(~(proc ra u.par) 1)
=+ c=b
|-
=+ foo=(matc +.poc c b)
=+ foo=(matc:poc c b)
?~ foo
?~ c
[~ ~]
$(c t.c)
[~ [~ (bar (dec -.poc) u.foo)]]
[~ [~ (bar (dec p.poc) u.foo)]]
::
++ repg :: Global regex replace
~/ %repg
@ -4123,12 +4086,12 @@
^- (unit tape)
=+ par=(pars a)
?~ par ~
=+ poc=(proc u.par 1)
=+ poc=(~(proc ra u.par) 1)
=+ d=b
:- ~
|-
^- tape
=+ foo=(matc +.poc d b)
=+ foo=(matc:poc d b)
?~ foo
?~ d
~
@ -4180,7 +4143,7 @@
++ xaro |=([a=@ b=@] +((mod (add (dec b) (sub 255 (mod a 255))) 255)))
::
++ zaft :: forward 255-sbox
|= a=@
|= a=@D
=+ ^= b
0xcc.75bc.86c8.2fb1.9a42.f0b3.79a0.92ca.21f6.1e41.cde5.fcc0.
7e85.51ae.1005.c72d.1246.07e8.7c64.a914.8d69.d9f4.59c2.8038.
@ -4196,7 +4159,7 @@
(cut 3 [(dec a) 1] b)
::
++ zart :: reverse 255-sbox
|= a=@
|= a=@D
=+ ^= b
0x68.4f07.ea1c.73c9.75c2.efc8.d559.5125.f621.a7a8.8591.5613.
dd52.40eb.65a2.60b7.4bcb.1123.ceb0.1bd6.3c84.2906.b164.19b3.
@ -4212,7 +4175,7 @@
(cut 3 [(dec a) 1] b)
::
++ zyft :: forward 256-sbox
|= a=@
|= a=@D
=+ ^= b
0xbb49.b71f.b881.b402.17e4.6b86.69b5.1647.115f.dddb.7ca5.
8371.4bd5.19a9.b092.605d.0d9b.e030.a0cc.78ba.5706.4d2d.
@ -4229,7 +4192,7 @@
(cut 3 [a 1] b)
::
++ zyrt :: reverse 256-sbox
|= a=@
|= a=@D
=+ ^= b
0x9fc8.2753.6e02.8fcf.8b35.2b20.5598.7caa.c9a9.30b0.9b48.
47ce.6371.80f6.407d.00dd.0aa5.ed10.ecb7.0f5a.5c3a.e605.
@ -4660,9 +4623,8 @@
$(hel t.hel, hev t.hev, rag (done %| [i.hel ~] [i.hev ~]))
--
++ nude :: tree change
|= [a=* b=*]
^- [p=upas q=upas]
=< [p=(tred a b) q=(tred b a)]
=< |= [a=* b=*] ^- [p=upas q=upas]
[p=(tred a b) q=(tred b a)]
|%
++ axes :: locs of nouns
|= [a=@ b=*] ^- (map ,* axis)
@ -4757,7 +4719,7 @@
?: =((mul 100 a) d)
~|(%ar-ramp !!)
=+ e=(~(raw og c) a)
?: &(|-(?~(b & &(!=(1 (mod e i.b)) $(b +.b)))) (pram e))
?: &((levy b |=(f=@ !=(1 (mod e f)))) (pram e))
e
$(c +(c), d (shax d))
::
@ -6127,7 +6089,6 @@
|= typ=type ^- tank
~(duck ut typ)
::
++ spat |=(pax=path (rap 3 (spud pax))) :: path to cord
++ spec :: reconstruct type
|= vax=vase
^- vase
@ -6139,7 +6100,6 @@
[%wtgr [%wtts [%leaf %tas -.q.vax] [%$ 2]~] [%$ 1]]
(~(fuse ut p.vax) [%cell %noun %noun])
::
++ spud |=(pax=path ~(ram re (dish:ut [~ %path] pax))) :: path to tape
++ slew :: get axis in vase
|= [axe=@ vax=vase] ^- (unit vase)
?. |- ^- ?
@ -6175,10 +6135,6 @@
[* * *] $(wad [n.wad ~ r.wad], vax $(wad l.wad))
==
::
++ stab :: parse cord to path
|= zep=@ta ^- path
(need (rush zep ;~(pfix fas ;~(sfix (more fas urs:ab) fas))))
::
++ wash :: render tank at width
|= [[tab=@ edg=@] tac=tank] ^- wall
(~(win re tac) tab edg)

View File

@ -443,7 +443,7 @@
::
++ unt :: UGT to UTC time
|= a=@
(div (sub a ~1970.1.1) (bex 64))
(div (sub a ~1970.1.1) ~s1)
::
++ yu :: UTC format constants
|%
@ -502,57 +502,38 @@
==
::
++ poja :: parse JSON
=< |=(a=cord (rush a apex))
|%
++ apex :: JSON object
;~(pose abox obox)
++ valu :: JSON value
++ apex :: JSON value
%+ knee *json |. ~+
;~ pfix spac
;~ pose
(cold ~ (jest 'null'))
(jify %b bool)
(jify %s stri)
(stag %b bool)
(stag %s stri)
(cook |=(s=tape [%n p=(rap 3 s)]) numb)
abox
obox
==
==
++ tops ;~(pose abox obox) :: JSON strict
:: JSON arrays
++ arra (ifix [sel (ws ser)] (more (ws com) valu))
++ abox (cook |=(elts=(list json) [%a p=elts]) arra)
++ abox (stag %a (ifix [sel (ws ser)] (more (ws com) apex)))
:: JSON objects
++ pair ;~((comp |=([k=@ta v=json] [k v])) ;~(sfix (ws stri) (ws col)) valu)
++ pair ;~(plug ;~(sfix (ws stri) (ws col)) apex)
++ obje (ifix [(ws kel) (ws ker)] (more (ws com) pair))
++ obox (cook |=(s=(list ,[@ta json]) [%o p=(mo s)]) obje)
++ obox (stag %o (cook mo obje))
:: JSON booleans
++ bool ;~(pose (cold & (jest 'true')) (cold | (jest 'false')))
:: JSON strings
++ stri
(cook |=(s=(list ,@) (rap 3 s)) (ifix [doq doq] (star jcha)))
++ jcha :: character in string
;~ pose
esca
;~ pose
:: Non-escape string characters
(shim 32 33)
(shim 35 91)
(shim 93 126)
(shim 128 255)
==
==
++ stri (cook crip (ifix [doq doq] (star jcha)))
++ jcha ;~(pose ;~(less doq bas prn) esca) :: character in string
++ esca :: Escaped character
;~ pfix bas
;~ pose
doq
fas
soq
bas
(cold 8 (just 'b'))
(cold 9 (just 't'))
(cold 10 (just 'n'))
(cold 12 (just 'f'))
(cold 13 (just 'r'))
;~(pfix (just 'u') (cook tuft qix:ab)) :: Convert 4-digit hex to UTF-8
doq fas soq bas
(sear ~(get by `(map ,@t ,@)`(mo b/8 t/9 n/10 f/12 r/13 ~)) low)
;~(pfix (just 'u') (cook tuft qix:ab)) :: 4-digit hex to UTF-8
==
==
:: JSON numbers
@ -561,7 +542,7 @@
(mayb (piec hep))
;~ pose
(piec (just '0'))
;~((comp twel) (piec (shim '1' '9')) digs)
;~(plug (shim '1' '9') digs)
==
(mayb frac)
(mayb expo)
@ -573,16 +554,11 @@
(mayb (piec (mask "+-")))
digs
==
++ frac :: Fractional part
;~ (comp twel)
(piec dot)
digs
==
++ frac ;~(plug dot digs) :: Fractional part
:: whitespace
++ spac (star (mask [`@`9 `@`10 `@`13 ' ' ~]))
++ ws |*(sef=_rule ;~(pfix spac sef))
:: plumbing
++ jify |*([t=@ta r=_rule] (cook |*([v=*] [t p=v]) r))
++ mayb |*(bus=_rule ;~(pose bus (easy "")))
++ twel |=([a=tape b=tape] (weld a b))
++ piec
@ -675,10 +651,15 @@
?. ?=([%s *] jon) ~
(bind (stud (trip p.jon)) |=(a=date (year a)))
::
++ di :: millisecond date
%- cu :_ ni
|= a=@u ^- @da
(add ~1970.1.1 (div (mul ~s1 a) 1.000))
::
++ mu :: true unit
|* wit=fist
|= jon=json
?~(jon (some ~) (wit jon))
?~(jon (some ~) (bind (wit jon) some))
::
++ ne :: number as real
|= jon=json
@ -688,7 +669,7 @@
++ ni :: number as integer
|= jon=json
?. ?=([%n *] jon) ~
(slaw %ui (cat 3 '0i' p.jon))
(rush p.jon dem)
::
++ no :: number as cord
|= jon=json
@ -723,10 +704,7 @@
|* wit=fist
|= jon=json
?. ?=([%o *] jon) ~
%- zm
|-
?~ p.jon ~
[n=[p=p.n.p.jon q=(wit q.n.p.jon)] l=$(p.jon l.p.jon) r=$(p.jon r.p.jon)]
(zm (~(run by p.jon) wit))
::
++ pe :: prefix
|* [pre=* wit=fist]
@ -770,46 +748,30 @@
u:->.but
[u:->.but (zp +.but)]
::
++ zt :: unit tuple
|* lut=(list (unit))
?: =(~ lut) ~
?. |- ^- ?
?~(lut & ?~(i.lut | $(lut t.lut)))
~
%- some
|-
?~ lut !!
?~ t.lut u:+.i.lut
[u:+.i.lut $(lut t.lut)]
::
++ zm :: collapse unit map
|* lum=(map term (unit))
?. |- ^- ?
?~(lum & ?~(q.n.lum | &($(lum l.lum) $(lum r.lum))))
?: (~(rep by lum) | |=([[@ a=(unit)] b=?] |(b ?=(~ a))))
~
%- some
|-
?~ lum ~
[[p.n.lum u:+.q.n.lum] $(lum l.lum) $(lum r.lum)]
(some (~(run by lum) need))
--
::
++ joba
++ joba :: object from k-v pair
|= [p=@t q=json]
^- json
[%o [[p q] ~ ~]]
::
++ jobe
++ jobe :: object from k-v list
|= a=(list ,[p=@t q=json])
^- json
[%o (~(gas by *(map ,@t json)) a)]
::
++ jape
++ jape :: string from tape
|= a=tape
^- json
[%s (crip a)]
::
++ jone
|= a=@
++ jone :: number from unsigned
|= a=@u
^- json
:- %n
?: =(0 a) '0'
@ -872,7 +834,7 @@
[(met 3 buf) buf]
::
++ txml :: string to xml
|= tep=tape ^- manx
|= tep=tape ^- mars
[[%$ [%$ tep] ~] ~]
::
++ xmla :: attributes to tape
@ -928,6 +890,7 @@
`_tam`?~(att bod [' ' (xmla att bod)])
::
++ xmlp :: xml parser
=< |=(a=cord (rush a apex))
|%
++ apex
=+ spa=;~(pose comt whit)
@ -939,27 +902,30 @@
empt
==
::
++ attr :: attribute
++ attr :: attributes
%+ knee *mart |. ~+
%- star
;~ pfix (plus whit)
;~ plug name
;~ pfix tis
;~ plug
;~(sfix name tis)
;~ pose
(ifix [doq doq] (star ;~(less doq escp)))
(ifix [soq soq] (star ;~(less soq escp)))
==
==
==
==
::
++ chrd :: character data
%+ knee *manx |. ~+
%+ cook |=(a=tape :/(a))
%+ cook |=(a=tape ^-(mars :/(a)))
(plus ;~(less soq doq ;~(pose (just `@`10) escp)))
::
++ comt %+ ifix [(jest '<!--') (jest '-->')] :: comments
(star ;~(less (jest '-->') ;~(pose whit prn)))
++ comt :: comments
=- (ifix [(jest '<!--') (jest '-->')] (star -))
;~ pose
;~(less hep prn)
whit
;~(less (jest '-->') hep)
==
::
++ escp
;~ pose
@ -971,15 +937,13 @@
(cold '\'' (jest '&apos;'))
==
++ empt :: self-closing tag
%+ ifix [gal ;~(plug (stun [0 1] ace) (jest '/>'))]
%+ ifix [gal (jest '/>')]
;~(plug ;~(plug name attr) (cold ~ (star whit)))
::
++ head :: opening tag
%+ knee *marx |. ~+
(ifix [gal gar] ;~(plug name attr))
::
++ name :: tag name
%+ knee *mane |. ~+
=+ ^= chx
%+ cook crip
;~ plug
@ -989,7 +953,7 @@
;~(pose ;~(plug ;~(sfix chx col) chx) chx)
::
++ tail (ifix [(jest '</') gar] name) :: closing tag
++ whit (mask ~[`@`0x20 `@`0x9 `@`0xa]) :: whitespace
++ whit (mask ~[' ' `@`0x9 `@`0xa]) :: whitespace
--
::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@ -1966,16 +1930,100 @@
+>
--
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: section 3bF, names etc ::
:: section 3bF, filesystem interface ::
::
++ clan :: ship to rank
|= who=ship ^- rank
=+ wid=(met 3 who)
?: (lte wid 1) %czar
?: =(2 wid) %king
?: (lte wid 4) %duke
?: (lte wid 8) %earl
?> (lte wid 16) %pawn
++ fain :: path restructure
|= [hom=path raw=path]
=+ bem=(need (tome raw))
=+ [mer=(flop s.bem) moh=(flop hom)]
|- ^- (pair beam path)
?~ moh
[bem(s hom) (flop mer)]
?> &(?=(^ mer) =(i.mer i.moh))
$(mer t.mer, moh t.moh)
::
++ feel :: simple file write
|= [pax=path val=*]
^- miso
=+ dir=((hard arch) .^(%cy pax))
?~ q.dir [%ins val]
:- %mut
^- udon
[%a %a .^(%cx pax) val]
::
++ file :: simple file load
|= pax=path
^- (unit)
=+ dir=((hard arch) .^(%cy pax))
?~(q.dir ~ [~ .^(%cx pax)])
::
++ foal :: high-level write
|= [pax=path val=*]
^- toro
?> ?=([* * * *] pax)
[i.t.pax [%& [*cart [[t.t.t.pax (feel pax val)] ~]]]]
::
++ fray :: high-level delete
|= pax=path
^- toro
?> ?=([* * * *] pax)
[i.t.pax [%& [*cart [[t.t.t.pax [%del .^(%cx pax)]] ~]]]]
::
++ furl :: unify changes
|= [one=toro two=toro]
^- toro
~| %furl
?> ?& =(p.one p.two) :: same path
&(?=(& -.q.one) ?=(& -.q.two)) :: both deltas
==
[p.one [%& [*cart (weld q.q.q.one q.q.q.two)]]]
::
++ meat :: kite to .^ path
|= kit=kite
^- path
[(cat 3 'c' p.kit) (scot %p r.kit) s.kit (scot `dime`q.kit) t.kit]
::
++ tame :: parse kite path
|= hap=path
^- (unit kite)
?. ?=([@ @ @ @ *] hap) ~
=+ :* hyr=(slay i.hap)
fal=(slay i.t.hap)
dyc=(slay i.t.t.hap)
ved=(slay i.t.t.t.hap)
:: ved=(slay i.t.hap)
:: fal=(slay i.t.t.hap)
:: dyc=(slay i.t.t.t.hap)
tyl=t.t.t.t.hap
==
?. ?=([~ %$ %tas @] hyr) ~
?. ?=([~ %$ %p @] fal) ~
?. ?=([~ %$ %tas @] dyc) ~
?. ?=([~ %$ case] ved) ~
=+ his=`@p`q.p.u.fal
=+ [dis=(end 3 1 q.p.u.hyr) rem=(rsh 3 1 q.p.u.hyr)]
?. ?&(?=(%c dis) ?=(?(%v %w %x %y %z) rem)) ~
[~ rem p.u.ved q.p.u.fal q.p.u.dyc tyl]
::
++ tome :: parse path to beam
|= pax=path
^- (unit beam)
?. ?=([* * * *] pax) ~
%+ biff (slaw %p i.pax)
|= who=ship
%+ biff (slaw %tas i.t.pax)
|= dex=desk
%+ biff (slay i.t.t.pax)
|= cis=coin
?. ?=([%$ case] cis) ~
`(unit beam)`[~ [who dex `case`p.cis] (flop t.t.t.pax)]
::
++ tope :: beam to path
|= bem=beam
^- path
[(scot %p p.bem) q.bem (scot r.bem) (flop s.bem)]
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: section 3bG, URL handling ::
::
++ deft :: import url path
|= rax=(list ,@t)
@ -1995,16 +2043,6 @@
:- p.pok
[i.rax q.pok]
::
++ fain :: path restructure
|= [hom=path raw=path]
=+ bem=(need (tome raw))
=+ [mer=(flop s.bem) moh=(flop hom)]
|- ^- (pair beam path)
?~ moh
[bem(s hom) (flop mer)]
?> &(?=(^ mer) =(i.mer i.moh))
$(mer t.mer, moh t.moh)
::
++ fest :: web synthesizer
|= [hom=path raw=path]
|* yax=$+(epic *)
@ -2071,6 +2109,22 @@
[~ zay]
[/html [/head (sip p.twa)] [/body (sip q.twa)] ~]
::
++ sifo :: 64-bit encode
|= tig=@
^- tape
=+ poc=(mod (sub 3 (mod (met 3 tig) 3)) 3)
=+ pad=(lsh 3 poc (swap 3 tig))
=+ ^= ska
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
=+ ^= sif
%- flop
|- ^- tape
?~ pad
~
=+ d=(end 0 6 pad)
[(snag d ska) $(pad (rsh 0 6 pad))]
(weld (scag (sub (lent sif) poc) sif) (trip (fil 3 poc '=')))
::
++ urle :: URL encode
|= tep=tape
^- tape
@ -2102,21 +2156,6 @@
?~(nex ~ [~ [`@`u.val u.nex]])
=+ nex=$(tep t.tep)
?~(nex ~ [~ i.tep u.nex])
++ sifo :: 64-bit encode
|= tig=@
^- tape
=+ poc=(mod (sub 3 (mod (met 3 tig) 3)) 3)
=+ pad=(lsh 3 poc (swap 3 tig))
=+ ^= ska
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
=+ ^= sif
%- flop
|- ^- tape
?~ pad
~
=+ d=(end 0 6 pad)
[(snag d ska) $(pad (rsh 0 6 pad))]
(weld (scag (sub (lent sif) poc) sif) (trip (fil 3 poc '=')))
::
++ earl :: local purl to tape
|= [who=@p pul=purl]
@ -2169,10 +2208,12 @@
--
::
++ epur :: url/header parser
=< |=(a=cord (rush a apex))
|%
++ apat :: 2396 abs_path
%+ cook deft
(ifix [fas ;~(pose fas (easy ~))] (more fas smeg))
++ apex auri
++ auri
%+ cook
|= a=purl
@ -2274,44 +2315,20 @@
==
--
::
++ feel :: simple file write
|= [pax=path val=*]
^- miso
=+ dir=((hard arch) .^(%cy pax))
?~ q.dir [%ins val]
:- %mut
^- udon
[%a %a .^(%cx pax) val]
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: section 3bH, names etc ::
::
++ file :: simple file load
|= pax=path
^- (unit)
=+ dir=((hard arch) .^(%cy pax))
?~(q.dir ~ [~ .^(%cx pax)])
::
++ foal :: high-level write
|= [pax=path val=*]
^- toro
?> ?=([* * * *] pax)
[i.t.pax [%& [*cart [[t.t.t.pax (feel pax val)] ~]]]]
::
++ fray :: high-level delete
|= pax=path
^- toro
?> ?=([* * * *] pax)
[i.t.pax [%& [*cart [[t.t.t.pax [%del .^(%cx pax)]] ~]]]]
::
++ furl :: unify changes
|= [one=toro two=toro]
^- toro
~| %furl
?> ?& =(p.one p.two) :: same path
&(?=(& -.q.one) ?=(& -.q.two)) :: both deltas
==
[p.one [%& [*cart (weld q.q.q.one q.q.q.two)]]]
++ clan :: ship to rank
|= who=ship ^- rank
=+ wid=(met 3 who)
?: (lte wid 1) %czar
?: =(2 wid) %king
?: (lte wid 4) %duke
?: (lte wid 8) %earl
?> (lte wid 16) %pawn
::
++ glam
|= zar=@p ^- tape
|= zar=@pD ^- tape
%+ snag zar
^- (list tape)
:~ "Tianming" "Pepin the Short" "Haile Selassie" "Alfred the Great"
@ -2560,6 +2577,14 @@
%zu [~ "Zulu"]
==
::
++ gnom :: ship display name
|= [[our=@p now=@da] him=@p] ^- @t
=+ yow=(scot %p him)
=+ pax=[(scot %p our) %name (scot %da now) yow ~]
=+ woy=((hard ,@t) .^(%a pax))
?: =(%$ woy) yow
(rap 3 yow ' ' woy ~)
::
++ gnow
|= [who=@p gos=gcos] ^- @t
?- -.gos
@ -2594,11 +2619,6 @@
?~ two one
?:((lth u.one u.two) one two)
::
++ meat :: kite to .^ path
|= kit=kite
^- path
[(cat 3 'c' p.kit) (scot %p r.kit) s.kit (scot (dime q.kit)) t.kit]
::
++ mojo :: compiling load
|= [pax=path src=*]
^- (each twig (list tank))
@ -2638,14 +2658,6 @@
?: ?=(| -.mud) mud
(mule |.((slam p.mud sam)))
::
++ numb :: ship display name
|= [him=@p our=@p now=@da] ^- @t
=+ yow=(scot %p him)
=+ pax=[(scot %p our) %name (scot %da now) yow ~]
=+ woy=((hard ,@t) .^(%a pax))
?: =(%$ woy) yow
(cat 3 yow (cat 3 ' ' woy))
::
++ saxo :: autocanon
|= who=ship
^- (list ship)
@ -2662,48 +2674,8 @@
%earl (end 5 1 who)
%pawn `@p`0
==
::
++ tame
|= hap=path
^- (unit kite)
?. ?=([@ @ @ @ *] hap) ~
=+ :* hyr=(slay i.hap)
fal=(slay i.t.hap)
dyc=(slay i.t.t.hap)
ved=(slay i.t.t.t.hap)
:: ved=(slay i.t.hap)
:: fal=(slay i.t.t.hap)
:: dyc=(slay i.t.t.t.hap)
tyl=t.t.t.t.hap
==
?. ?=([~ %$ %tas @] hyr) ~
?. ?=([~ %$ %p @] fal) ~
?. ?=([~ %$ %tas @] dyc) ~
?. ?=(^ ved) ~
=+ his=`@p`q.p.u.fal
=+ [dis=(end 3 1 q.p.u.hyr) rem=(rsh 3 1 q.p.u.hyr)]
?. ?&(?=(%c dis) ?=(?(%v %w %x %y %z) rem)) ~
[~ rem (case p.u.ved) q.p.u.fal q.p.u.dyc tyl]
::
++ tome :: parse path
|= pax=path
^- (unit beam)
?. ?=([* * * *] pax) ~
%+ biff (slaw %p i.pax)
|= who=ship
%+ biff (slaw %tas i.t.pax)
|= dex=desk
%+ biff (slay i.t.t.pax)
|= cis=coin
?. ?=([%$ case] cis) ~
`(unit beam)`[~ [who dex `case`p.cis] (flop t.t.t.pax)]
::
++ tope :: beam to path
|= bem=beam
^- path
[(scot %p p.bem) q.bem (scot r.bem) (flop s.bem)]
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: section 3bG, Arvo models ::
:: section 3bI, Arvo models ::
::
++ acru :: asym cryptosuite
$_ ^? |% :: opaque object

View File

@ -360,8 +360,8 @@
?^ act
(rap 3 (~(got by cub.hid) u.act) '(' u.act ') ' ~)
?. &(?=([@ @ @ *] pax) =('0' &3.pax))
(spat pax)
(rap 3 '/' &1.pax '/' &2.pax '=' ?~(|3.pax ~ [(spat |3.pax)]~))
(rsh 3 1 (spat pax))
(rap 3 &1.pax '/' &2.pax '=' ?~(|3.pax ~ [(spat |3.pax)]~))
++ exec
|= gen=twig
%- slap :_ gen

View File

@ -3,9 +3,9 @@
:::: /hook/hymn/front/twit/app
::
/? 314 :: need urbit 314
/= urbit /:/===/lib/urb:/hymn/ :: urbit library (js)
/= style /:/%%%/style:/hymn/ :: stylesheet (css)
/= application /:/%%%/app:/hymn/ :: application (js)
/= urbit /:/===/lib/urb:/psal/ :: urbit library (js)
/= style /:/%%%/style:/psal/ :: stylesheet (css)
/= application /:/%%%/app:/psal/ :: application (js)
!:
:::: content
::

View File

@ -7,5 +7,10 @@
++ grab :: convert from
|%
++ noun ,@t :: clam from %noun
++ json (cork so:jo need)
--
++ grow
|%
++ psal ;div: {(trip txt)}
--
--