on 140ac0e help sign in
356 lines 7.6 kB history raw
1# 4c: tank printer
2### `++re`
4Pretty-printing engine
6Pretty-printing engine that accepts a `++tank` sample and contains arms that perform computation on it.
8Accepts
9-------
11`tac` is a `++tank`.
13Produces
14--------
16 ++ re
17 |_ tac/tank
19Examples
20--------
22 /> ~(. re leaf+"ham")
23 <2.gdc {tac/{$leaf ""} <402.arm 110.jyx 1.ztu $151>}>
25### `++ram`
27Flatten to tape
29Flatten `++tank` out into a `++tape`.
31Accepts
32-------
34`tac` is a `++tank`, taken from sample of `++re` core.
36Produces
37--------
39A `++tape`.
41Source
42------
44 ++ ram
45 ^- tape
46 ?- -.tac
47 $leaf p.tac
48 $palm ram(tac [%rose [p.p.tac (weld q.p.tac r.p.tac) s.p.tac] q.tac])
49 $rose
50 %+ weld
51 q.p.tac
52 |- ^- tape
53 ?~ q.tac
54 r.p.tac
55 =+ voz=$(q.tac t.q.tac)
56 (weld ram(tac i.q.tac) ?~(t.q.tac voz (weld p.p.tac voz)))
57 ==
58 ::
60Examples
61--------
63 /> ~(ram re leaf+"foo")
64 "foo"
65 /> ~(ram re rose+["." "(" ")"]^~[leaf+"bar" leaf+"baz" leaf+"bam"])
66 "(bar.baz.bam)"
68### `++win`
70Render at indent
72Render at indent level `tab` and width `edg`.
74Accepts
75-------
77`tac` is a `++tank`, taken from sample of `++re` core.
79`tab` and `edg` are atoms.
81Produces
82--------
84A `++wall` (`++list` of `++tapes`).
86Source
87------
89 ++ win
90 |= {tab/@ edg/@}
91 =+ lug=`wall`~
92 |^ |- ^- wall
93 ?- -.tac
94 $leaf (rig p.tac)
95 $palm
96 ?: fit
97 (rig ram)
98 ?~ q.tac
99 (rig q.p.tac)
100 ?~ t.q.tac
101 (rig(tab (add 2 tab), lug $(tac i.q.tac)) q.p.tac)
102 => .(q.tac `(list tank)`q.tac)
103 =+ lyn=(mul 2 (lent q.tac))
104 =+ ^= qyr
105 |- ^- wall
106 ?~ q.tac
107 lug
108 %= ^$
109 tac i.q.tac
110 tab (add tab (sub lyn 2))
111 lug $(q.tac t.q.tac, lyn (sub lyn 2))
112 ==
113 (wig(lug qyr) q.p.tac)
114 ::
116Examples
117--------
119 /> (~(win re leaf+"samoltekon-lapdok") 0 20)
120 <<"samoltekon-lapdok">>
121 /> (~(win re leaf+"samoltekon-lapdok") 0 10)
122 <<"\/samolt\/" " ekon-l" " apdok" "\/ \/">>
123 /> (~(win re rose+["--" "[" "]"]^~[leaf+"1423" leaf+"2316"]) 0 20)
124 <<"[1423--2316]">>
125 /> (~(win re rose+["--" "[" "]"]^~[leaf+"1423" leaf+"2316"]) 0 10)
126 <<"[ 1423" " 2316" "]">>
128### `++din`
130XX document
132Accepts
133-------
135Produces
136--------
138Source
139------
141 ++ din (mod (add 2 tab) (mul 2 (div edg 3)))
144----------------------------------------------------------------------
146### `++fit`
148Fit on one line test
150Determine whether `tac` fits on one line. Internal to `++win`
152Accepts
153-------
155Produces
156--------
158Source
159------
161++ fit (lte (lent ram) (sub edg tab))
164Examples
165--------
170----------------------------------------------------------------------
172### `++rig`
174Wrap in `\/`
176Wrap `++tape` in `\/` if it doesn't fit at current indentation. Internal to
177`++win`
179Accepts
180-------
182`tac` is a `++tank`, taken from sample of `++re` core.
184`hom` is a `++tape`.
186Produces
187--------
189A `++wall` (list of `++tape`s).
191Source
192------
194 ++ rig
195 |= hom/tape
196 ^- wall
197 ?: & ::(lte (lent hom) (sub edg tab))
198 [(runt [tab ' '] hom) lug]
199 => .(tab (add tab 2), edg (sub edg 2))
200 =+ mut=(trim (sub edg tab) hom)
201 :- (runt [(sub tab 2) ' '] ['\\' '/' (weld p.mut `_hom`['\\' '/' ~])])
202 => .(hom q.mut)
203 |-
204 ?~ hom
205 :- %+ runt
206 [(sub tab 2) ' ']
207 ['\\' '/' (runt [(sub edg tab) ' '] ['\\' '/' ~])]
208 lug
209 => .(mut (trim (sub edg tab) hom))
210 [(runt [tab ' '] p.mut) $(hom q.mut)]
211 ::
213Examples
214--------
216### `++wig`
218`++win` render tape
220Render `++tape`. Internal to `++win`.
222Accepts
223-------
225`tac` is a `++tank`, taken from sample of `++re` core.
227`hom` is a `++tape`.
229Produces
230--------
232 ++ wig
233 |= hom/tape
234 ^- wall
235 ?~ lug
236 (rig hom)
237 =+ lin=(lent hom)
238 =+ wug=:(add 1 tab lin)
239 ?. =+ mir=i.lug
240 |- ?~ mir
241 |
242 ?|(=(0 wug) ?&(=(' ' i.mir) $(mir t.mir, wug (dec wug))))
243 (rig hom) :: ^ XX regular form?
244 [(runt [tab ' '] (weld hom `tape`[' ' (slag wug i.lug)])) t.lug]
245 --
246 --
251***
252### `++show`
254 ++ show :: XX deprecated, use span
255 |= vem/*
256 |^ ^- tank
257 ?: ?=(@ vem)
258 [%leaf (mesc (trip vem))]
259 ?- vem
260 {s/$~ c/*}
261 [%leaf '\'' (weld (mesc (tape +.vem)) `tape`['\'' ~])]
262 ::
263 {s/$a c/@} [%leaf (mesc (trip c.vem))]
264 {s/$b c/*} (shop c.vem |=(a/@ ~(rub at a)))
265 {s/{$c p/@} c/*}
266 :+ %palm
267 [['.' ~] ['-' ~] ~ ~]
268 [[%leaf (mesc (trip p.s.vem))] $(vem c.vem) ~]
269 ::
270 {s/$d c/*} (shop c.vem |=(a/@ ~(rud at a)))
271 {s/$k c/*} (tank c.vem)
272 {s/$h c/*}
273 :+ %rose
274 [['/' ~] ['/' ~] ~]
275 =+ yol=((list @ta) c.vem)
276 (turn yol |=(a/@ta [%leaf (trip a)]))
277 ::
278 {s/$l c/*} (shol c.vem)
279 {s/$o c/*}
280 %= $
281 vem
282 :- [%m '%h:<[%d %d].[%d %d]>']
283 [-.c.vem +<-.c.vem +<+.c.vem +>-.c.vem +>+.c.vem ~]
284 ==
285 ::
286 {s/$p c/*} (shop c.vem |=(a/@ ~(rup at a)))
287 {s/$q c/*} (shop c.vem |=(a/@ ~(r at a)))
288 {s/$r c/*} $(vem [[%r ' ' '{' '}'] c.vem])
289 {s/$t c/*} (shop c.vem |=(a/@ ~(rt at a)))
290 {s/$v c/*} (shop c.vem |=(a/@ ~(ruv at a)))
291 {s/$x c/*} (shop c.vem |=(a/@ ~(rux at a)))
292 {s/{$m p/@} c/*} (shep p.s.vem c.vem)
293 {s/{$r p/@} c/*}
294 $(vem [[%r ' ' (cut 3 [0 1] p.s.vem) (cut 3 [1 1] p.s.vem)] c.vem])
295 ::
296 {s/{$r p/@ q/@ r/@} c/*}
297 :+ %rose
298 :* p=(mesc (trip p.s.vem))
299 q=(mesc (trip q.s.vem))
300 r=(mesc (trip r.s.vem))
301 ==
302 |- ^- (list tank)
303 ?@ c.vem
304 ~
305 [^$(vem -.c.vem) $(c.vem +.c.vem)]
306 ::
307 {s/$z c/*} $(vem [[%r %$ %$ %$] c.vem])
308 * !!
309 ==
311XX document
313### `++shep`
315 ++ shep
316 |= {fom/@ gar/*}
317 ^- tank
318 =+ l=(met 3 fom)
319 =+ i=0
320 :- %leaf
321 |- ^- tape
322 ?: (gte i l)
323 ~
324 =+ c=(cut 3 [i 1] fom)
325 ?. =(37 c)
326 (weld (mesc [c ~]) $(i +(i)))
327 =+ d=(cut 3 [+(i) 1] fom)
328 ?. .?(gar)
329 ['\\' '#' $(i (add 2 i))]
330 (weld ~(ram re (show d -.gar)) $(i (add 2 i), gar +.gar))
331 ::
333XX document
335### `++shop`
337 ++ shop
338 |= {aug/* vel/$-(a/@ tape)}
339 ^- tank
340 ?: ?=(@ aug)
341 [%leaf (vel aug)]
342 :+ %rose
343 [[' ' ~] ['[' ~] [']' ~]]
344 => .(aug `*`aug)
345 |- ^- (list tank)
346 ?: ?=(@ aug)
347 [^$ ~]
348 [^$(aug -.aug) $(aug +.aug)]
349 ::
352XX document
356***