on b93c19b help sign in
363 lines 7.5 kB history raw
1+++
2title = "4c: Tank Printer"
3weight = 30
4template = "doc.html"
5+++
6### `++re`
8Pretty-printing engine
10Pretty-printing engine that accepts a `++tank` sample and contains arms that perform computation on it.
12#### Accepts
14`tac` is a `++tank`.
16#### Produces
18```
19 ++ re
20 |_ tac/tank
21```
23#### Examples
25```
26 > ~(. re leaf+"ham")
27 <2.gdc {tac/{$leaf ""} <402.arm 110.jyx 1.ztu $151>}>
28```
30---
31### `++ram:re`
33Flatten to tape
35Flatten `++tank` out into a `++tape`.
37#### Accepts
39`tac` is a `++tank`, taken from sample of `++re` core.
41#### Produces
43A `++tape`.
45#### Source
47```
48 ++ ram
49 ^- tape
50 ?- -.tac
51 $leaf p.tac
52 $palm ram(tac [%rose [p.p.tac (weld q.p.tac r.p.tac) s.p.tac] q.tac])
53 $rose
54 %+ weld
55 q.p.tac
56 |- ^- tape
57 ?~ q.tac
58 r.p.tac
59 =+ voz=$(q.tac t.q.tac)
60 (weld ram(tac i.q.tac) ?~(t.q.tac voz (weld p.p.tac voz)))
61 ==
62 ::
63```
65#### Examples
67```
68 > ~(ram re leaf+"foo")
69 "foo"
70 > ~(ram re rose+["." "(" ")"]^~[leaf+"bar" leaf+"baz" leaf+"bam"])
71 "(bar.baz.bam)"
72```
73---
74### `++win:re`
76Render at indent
78Render at indent level `tab` and width `edg`.
80#### Accepts
82`tac` is a `++tank`, taken from sample of `++re` core.
84`tab` and `edg` are atoms.
86#### Produces
88A `++wall` (`++list` of `++tapes`).
90#### Source
92```
93 ++ win
94 |= {tab/@ edg/@}
95 =+ lug=`wall`~
96 |^ |- ^- wall
97 ?- -.tac
98 $leaf (rig p.tac)
99 $palm
100 ?: fit
101 (rig ram)
102 ?~ q.tac
103 (rig q.p.tac)
104 ?~ t.q.tac
105 (rig(tab (add 2 tab), lug $(tac i.q.tac)) q.p.tac)
106 => .(q.tac `(list tank)`q.tac)
107 =+ lyn=(mul 2 (lent q.tac))
108 =+ ^= qyr
109 |- ^- wall
110 ?~ q.tac
111 lug
112 %= ^$
113 tac i.q.tac
114 tab (add tab (sub lyn 2))
115 lug $(q.tac t.q.tac, lyn (sub lyn 2))
116 ==
117 (wig(lug qyr) q.p.tac)
118 ::
119```
121#### Examples
123```
124 > (~(win re leaf+"samoltekon-lapdok") 0 20)
125 <<"samoltekon-lapdok">>
127 > (~(win re leaf+"samoltekon-lapdok") 0 10)
128 <<"\/samolt\/" " ekon-l" " apdok" "\/ \/">>
130 > (~(win re rose+["--" "[" "]"]^~[leaf+"1423" leaf+"2316"]) 0 20)
131 <<"[1423--2316]">>
133 > (~(win re rose+["--" "[" "]"]^~[leaf+"1423" leaf+"2316"]) 0 10)
134 <<"[ 1423" " 2316" "]">>
135```
137---
138### `++din:re`
140XX document
142#### Accepts
144#### Produces
146#### Source
148 ++ din (mod (add 2 tab) (mul 2 (div edg 3)))
151---
153### `++fit:re`
155Fit on one line test
157Determine whether `tac` fits on one line. Internal to `++win`
159#### Accepts
161#### Produces
163#### Source
165++ fit (lte (lent ram) (sub edg tab))
168#### Examples
173---
175### `++rig:re`
177Wrap in `\/`
179Wrap `++tape` in `\/` if it doesn't fit at current indentation. Internal to
180`++win`
182#### Accepts
184`tac` is a `++tank`, taken from sample of `++re` core.
186`hom` is a `++tape`.
188#### Produces
190A `++wall` (list of `++tape`s).
192#### Source
194```
195 ++ rig
196 |= hom/tape
197 ^- wall
198 ?: & ::(lte (lent hom) (sub edg tab))
199 [(runt [tab ' '] hom) lug]
200 => .(tab (add tab 2), edg (sub edg 2))
201 =+ mut=(trim (sub edg tab) hom)
202 :- (runt [(sub tab 2) ' '] ['\\' '/' (weld p.mut `_hom`['\\' '/' ~])])
203 => .(hom q.mut)
204 |-
205 ?~ hom
206 :- %+ runt
207 [(sub tab 2) ' ']
208 ['\\' '/' (runt [(sub edg tab) ' '] ['\\' '/' ~])]
209 lug
210 => .(mut (trim (sub edg tab) hom))
211 [(runt [tab ' '] p.mut) $(hom q.mut)]
212 ::
213```
215#### Examples
217---
218### `++wig:re`
220`++win` render tape
222Render `++tape`. Internal to `++win`.
224#### Accepts
226`tac` is a `++tank`, taken from sample of `++re` core.
228`hom` is a `++tape`.
230#### Produces
232```
233 ++ wig
234 |= hom/tape
235 ^- wall
236 ?~ lug
237 (rig hom)
238 =+ lin=(lent hom)
239 =+ wug=:(add 1 tab lin)
240 ?. =+ mir=i.lug
241 |- ?~ mir
242 |
243 ?|(=(0 wug) ?&(=(' ' i.mir) $(mir t.mir, wug (dec wug))))
244 (rig hom) :: ^ XX regular form?
245 [(runt [tab ' '] (weld hom `tape`[' ' (slag wug i.lug)])) t.lug]
246 --
247 --
248```
252---
253### `++show`
255```
256 ++ show :: XX deprecated, use span
257 |= vem/*
258 |^ ^- tank
259 ?: ?=(@ vem)
260 [%leaf (mesc (trip vem))]
261 ?- vem
262 {s/$~ c/*}
263 [%leaf '\'' (weld (mesc (tape +.vem)) `tape`['\'' ~])]
264 ::
265 {s/$a c/@} [%leaf (mesc (trip c.vem))]
266 {s/$b c/*} (shop c.vem |=(a/@ ~(rub at a)))
267 {s/{$c p/@} c/*}
268 :+ %palm
269 [['.' ~] ['-' ~] ~ ~]
270 [[%leaf (mesc (trip p.s.vem))] $(vem c.vem) ~]
271 ::
272 {s/$d c/*} (shop c.vem |=(a/@ ~(rud at a)))
273 {s/$k c/*} (tank c.vem)
274 {s/$h c/*}
275 :+ %rose
276 [['/' ~] ['/' ~] ~]
277 =+ yol=((list @ta) c.vem)
278 (turn yol |=(a/@ta [%leaf (trip a)]))
279 ::
280 {s/$l c/*} (shol c.vem)
281 {s/$o c/*}
282 %= $
283 vem
284 :- [%m '%h:<[%d %d].[%d %d]>']
285 [-.c.vem +<-.c.vem +<+.c.vem +>-.c.vem +>+.c.vem ~]
286 ==
287 ::
288 {s/$p c/*} (shop c.vem |=(a/@ ~(rup at a)))
289 {s/$q c/*} (shop c.vem |=(a/@ ~(r at a)))
290 {s/$r c/*} $(vem [[%r ' ' '{' '}'] c.vem])
291 {s/$t c/*} (shop c.vem |=(a/@ ~(rt at a)))
292 {s/$v c/*} (shop c.vem |=(a/@ ~(ruv at a)))
293 {s/$x c/*} (shop c.vem |=(a/@ ~(rux at a)))
294 {s/{$m p/@} c/*} (shep p.s.vem c.vem)
295 {s/{$r p/@} c/*}
296 $(vem [[%r ' ' (cut 3 [0 1] p.s.vem) (cut 3 [1 1] p.s.vem)] c.vem])
297 ::
298 {s/{$r p/@ q/@ r/@} c/*}
299 :+ %rose
300 :* p=(mesc (trip p.s.vem))
301 q=(mesc (trip q.s.vem))
302 r=(mesc (trip r.s.vem))
303 ==
304 |- ^- (list tank)
305 ?@ c.vem
306 ~
307 [^$(vem -.c.vem) $(c.vem +.c.vem)]
308 ::
309 {s/$z c/*} $(vem [[%r %$ %$ %$] c.vem])
310 * !!
311 ==
312```
314XX document
316### `++shep`
318```
319 ++ shep
320 |= {fom/@ gar/*}
321 ^- tank
322 =+ l=(met 3 fom)
323 =+ i=0
324 :- %leaf
325 |- ^- tape
326 ?: (gte i l)
327 ~
328 =+ c=(cut 3 [i 1] fom)
329 ?. =(37 c)
330 (weld (mesc [c ~]) $(i +(i)))
331 =+ d=(cut 3 [+(i) 1] fom)
332 ?. .?(gar)
333 ['\\' '#' $(i (add 2 i))]
334 (weld ~(ram re (show d -.gar)) $(i (add 2 i), gar +.gar))
335 ::
336```
338XX document
340### `++shop`
342```
343 ++ shop
344 |= {aug/* vel/$-(a/@ tape)}
345 ^- tank
346 ?: ?=(@ aug)
347 [%leaf (vel aug)]
348 :+ %rose
349 [[' ' ~] ['[' ~] [']' ~]]
350 => .(aug `*`aug)
351 |- ^- (list tank)
352 ?: ?=(@ aug)
353 [^$ ~]
354 [^$(aug -.aug) $(aug +.aug)]
355 ::
356```
359XX document
363---