urbit/mar/snip.hoon

70 lines
1.7 KiB
Plaintext
Raw Normal View History

2015-02-05 01:59:15 +03:00
::
2015-06-06 01:20:26 +03:00
:::: /hoon/core/elem/mar
2015-02-05 01:59:15 +03:00
::
/? 314
!:
|%
2015-02-17 23:53:06 +03:00
++ words 1
2015-02-05 01:59:15 +03:00
++ hedtal
2015-02-17 23:53:06 +03:00
|= a=marl ^- [hed=marl tal=marl]
2015-02-05 01:59:15 +03:00
?~ a [~ ~]
?. ?=(%h1 n.g.i.a)
=+ had=$(a c.i.a)
?^ -.had had
$(a t.a)
2015-02-17 23:53:06 +03:00
[c.i.a (limit words t.a)]
2015-02-05 01:59:15 +03:00
::
++ extract
|= a=marl ^- tape
?~ a ~
%- weld :_ $(a t.a)
?. ?=(_:/(**) i.a)
$(a c.i.a)
v.i.a.g.i.a
::
++ limit
|= [lim=@u mal=marl]
=< res
|- ^- [rem=@u res=marl]
?~ mal [lim ~]
?~ lim [0 ~]
=+ ^- [lam=@u hed=manx]
?: ?=(_:/(**) i.mal)
[lim :/(tay)]:(deword lim v.i.a.g.i.mal)
[rem ele(c res)]:[ele=i.mal $(mal c.i.mal)]
[rem - res]:[hed $(lim lam, mal t.mal)]
::
++ deword
|= [lim=@u tay=tape] ^- [lim=@u tay=tape]
?~ tay [lim tay]
?~ lim [0 ~]
2015-02-17 23:53:06 +03:00
=+ wer=(dot 1^1 tay)
2015-02-05 01:59:15 +03:00
?~ q.wer
[lim - tay]:[i.tay $(tay t.tay)]
=+ nex=$(lim (dec lim), tay q.q.u.q.wer)
2015-02-17 23:53:06 +03:00
[-.nex [(wonk wer) +.nex]]
2015-02-05 01:59:15 +03:00
--
::
!:
|_ own=manx
::
++ grow :: convert to
|%
2015-02-14 06:41:37 +03:00
++ mime
=< mime
|%
2015-06-06 01:20:26 +03:00
++ elem own
++ hymn ;html:(head:title:"snip" body:"+{elem}") :: convert to %hymn
2015-02-14 06:41:37 +03:00
++ html (crip (poxo hymn)) :: convert to %html
++ mime [/text/html (taco html)] :: convert to %mime
--
2015-02-05 01:59:15 +03:00
--
++ garb [%react-snip ~]
++ grab |% :: convert from
++ noun manx :: clam from %noun
2015-06-06 01:20:26 +03:00
++ elem
2015-02-05 01:59:15 +03:00
|= a=manx
=+ (hedtal +.a)
2015-02-17 23:53:06 +03:00
;div:(h1:"*{hed}" div:"*{tal}")
2015-02-05 01:59:15 +03:00
-- --