urbit/pub/docs/dev/hoon/library/2ez.md

251 lines
5.4 KiB
Markdown
Raw Normal View History

2015-02-18 06:03:21 +03:00
section 2eZ, OLD rendering
2015-04-23 03:43:52 +03:00
==========================
2015-02-18 06:03:21 +03:00
2015-08-12 00:32:57 +03:00
### `++show`
2015-02-18 06:03:21 +03:00
++ show :: XX deprecated, use type
|= vem=*
|^ ^- tank
?: ?=(@ vem)
[%leaf (mesc (trip vem))]
?- vem
[s=~ c=*]
[%leaf '\'' (weld (mesc (tape +.vem)) `tape`['\'' ~])]
::
[s=%a c=@] [%leaf (mesc (trip c.vem))]
[s=%b c=*] (shop c.vem |=(a=@ ~(rub at a)))
[s=[%c p=@] c=*]
:+ %palm
[['.' ~] ['-' ~] ~ ~]
[[%leaf (mesc (trip p.s.vem))] $(vem c.vem) ~]
::
[s=%d c=*] (shop c.vem |=(a=@ ~(rud at a)))
[s=%k c=*] (tank c.vem)
[s=%h c=*]
?: =(0 c.vem) :: XX remove after 220
[%leaf '#' ~]
:+ %rose
[['/' ~] ['/' ~] ~]
=+ yol=((list ,@ta) c.vem)
(turn yol |=(a=@ta [%leaf (trip a)]))
::
[s=%o c=*]
%= $
vem
:- [%m '%h:<[%d %d].[%d %d]>']
[-.c.vem +<-.c.vem +<+.c.vem +>-.c.vem +>+.c.vem ~]
==
::
[s=%p c=*] (shop c.vem |=(a=@ ~(rup at a)))
[s=%q c=*] (shop c.vem |=(a=@ ~(r at a)))
[s=%r c=*] $(vem [[%r ' ' '{' '}'] c.vem])
[s=%t c=*] (shop c.vem |=(a=@ ~(rt at a)))
[s=%v c=*] (shop c.vem |=(a=@ ~(ruv at a)))
[s=%x c=*] (shop c.vem |=(a=@ ~(rux at a)))
[s=[%m p=@] c=*] (shep p.s.vem c.vem)
[s=[%r p=@] c=*]
$(vem [[%r ' ' (cut 3 [0 1] p.s.vem) (cut 3 [1 1] p.s.vem)] c.vem])
::
[s=[%r p=@ q=@ r=@] c=*]
:+ %rose
:* p=(mesc (trip p.s.vem))
q=(mesc (trip q.s.vem))
r=(mesc (trip r.s.vem))
==
|- ^- (list tank)
?@ c.vem
~
[^$(vem -.c.vem) $(c.vem +.c.vem)]
::
[s=%z c=*] $(vem [[%r %$ %$ %$] c.vem])
* !!
==
XX document
2015-08-12 00:32:57 +03:00
### `++shep`
2015-02-18 06:03:21 +03:00
++ shep
|= [fom=@ gar=*]
^- tank
=+ l=(met 3 fom)
=+ i=0
:- %leaf
|- ^- tape
?: (gte i l)
~
=+ c=(cut 3 [i 1] fom)
?. =(37 c)
(weld (mesc [c ~]) $(i +(i)))
=+ d=(cut 3 [+(i) 1] fom)
?. .?(gar)
['\\' '#' $(i (add 2 i))]
(weld ~(ram re (show d -.gar)) $(i (add 2 i), gar +.gar))
::
XX document
2015-08-12 00:32:57 +03:00
### `++shop`
2015-02-18 06:03:21 +03:00
++ shop
|= [aug=* vel=$+(a=@ tape)]
^- tank
?: ?=(@ aug)
[%leaf (vel aug)]
:+ %rose
[[' ' ~] ['[' ~] [']' ~]]
=> .(aug `*`aug)
|- ^- (list tank)
?: ?=(@ aug)
[^$ ~]
[^$(aug -.aug) $(aug +.aug)]
--
XX document
2015-08-12 00:32:57 +03:00
### `++at`
2015-02-18 06:03:21 +03:00
++ at
|_ a=@
XX document
2015-08-12 00:32:57 +03:00
### `++r`
2015-02-18 06:03:21 +03:00
++ r
?: ?& (gte (met 3 a) 2)
|-
?: =(0 a)
&
=+ vis=(end 3 1 a)
?& ?|(=('-' vis) ?&((gte vis 'a') (lte vis 'z')))
$(a (rsh 3 1 a))
==
==
rtam
?: (lte (met 3 a) 2)
rud
rux
::
XX document
2015-08-12 00:32:57 +03:00
### `++rf`
2015-02-18 06:03:21 +03:00
++ rf `tape`[?-(a & '&', | '|', * !!) ~]
XX document
2015-08-12 00:32:57 +03:00
### `++rn`
2015-02-18 06:03:21 +03:00
++ rn `tape`[?>(=(0 a) '~') ~]
XX document
2015-08-12 00:32:57 +03:00
### `++rt`
2015-02-18 06:03:21 +03:00
++ rt `tape`['\'' (weld (mesc (trip a)) `tape`['\'' ~])]
XX document
2015-08-12 00:32:57 +03:00
### `++rta`
2015-02-18 06:03:21 +03:00
++ rta rt
XX document
2015-08-12 00:32:57 +03:00
### `++rtam`
2015-02-18 06:03:21 +03:00
++ rtam `tape`['%' (trip a)]
XX document
2015-08-12 00:32:57 +03:00
### `++rub`
2015-02-18 06:03:21 +03:00
++ rub `tape`['0' 'b' (rum 2 ~ |=(b=@ (add '0' b)))]
XX document
2015-08-12 00:32:57 +03:00
### `++rud`
2015-02-18 06:03:21 +03:00
++ rud (rum 10 ~ |=(b=@ (add '0' b)))
XX document
2015-08-12 00:32:57 +03:00
### `++rum`
2015-02-18 06:03:21 +03:00
++ rum
|= [b=@ c=tape d=$+(@ @)]
^- tape
?: =(0 a)
[(d 0) c]
=+ e=0
|- ^- tape
?: =(0 a)
c
=+ f=&(!=(0 e) =(0 (mod e ?:(=(10 b) 3 4))))
%= $
a (div a b)
c [(d (mod a b)) ?:(f [?:(=(10 b) ',' '-') c] c)]
e +(e)
==
::
XX document
2015-08-12 00:32:57 +03:00
### `++rup`
2015-02-18 06:03:21 +03:00
++ rup
=+ b=(met 3 a)
^- tape
:- '-'
|- ^- tape
?: (gth (met 5 a) 1)
%+ weld
$(a (rsh 5 1 a), b (sub b 4))
`tape`['-' '-' $(a (end 5 1 a), b 4)]
?: =(0 b)
['~' ~]
?: (lte b 1)
(trip (tos:po a))
|- ^- tape
?: =(2 b)
=+ c=(rsh 3 1 a)
=+ d=(end 3 1 a)
(weld (trip (tod:po c)) (trip (tos:po (mix c d))))
=+ c=(rsh 3 2 a)
=+ d=(end 3 2 a)
(weld ^$(a c, b (met 3 c)) `tape`['-' $(a (mix c d), b 2)])
::
XX document
2015-08-12 00:32:57 +03:00
### `++ruv`
2015-02-18 06:03:21 +03:00
++ ruv
^- tape
:+ '0'
'v'
%^ rum
64
~
|= b=@
?: =(63 b)
'+'
?: =(62 b)
'-'
?:((lth b 26) (add 65 b) ?:((lth b 52) (add 71 b) (sub b 4)))
::
XX document
2015-08-12 00:32:57 +03:00
### `++rux`
2015-02-18 06:03:21 +03:00
++ rux `tape`['0' 'x' (rum 16 ~ |=(b=@ (add b ?:((lth b 10) 48 87))))]
--
:::::::::::::::::::::::::::::::::::::::::::::::::::::: ::
XX document
------------------------------------------------------------------------