on 140ac0e help sign in
416 lines 6.4 kB history raw
1# 4m: formatting functions
2### `++scot`
4Render dime as cord
6Renders a dime `mol` as a cord.
8Accepts
9-------
11Produces
12--------
14`mol` is a `++dime`.
16Source
17------
19 ++ scot |=(mol/dime ~(rent co %$ mol))
21Examples
22--------
24 > (scot %p ~pillyt)
25 ~.~pillyt
26 > `@t`(scot %p ~pillyt)
27 '~pillyt'
28 > (scot %ux 0x12)
29 ~.0x12
30 > `@t`(scot %ux 0x12)
31 '0x12'
32 > (scot %if .127.0.0.1)
33 ~..127.0.0.1
34 > `@t`(scot %if .127.0.0.1)
35 '.127.0.0.1'
36 > (scot %ta ~.asd_a)
37 ~.~.asd_a
38 > `@t`(scot %ta ~.asd_a)
39 '~.asd_a'
43***
44### `++scow`
46Render dime as tape
48Renders `mol` as a tape.
50Accepts
51-------
53Produces
54--------
56`mol` is a `++dime`.
58Source
59------
61 ++ scow |=(mol/dime ~(rend co %$ mol))
63Examples
64--------
66 > (scow %p ~pillyt)
67 "~pillyt"
68 > (scow %ux 0x12)
69 "0x12"
70 > (scow %if .127.0.0.1)
71 ".127.0.0.1"
72 > (scow %ta ~.asd_a)
73 "~.asd_a"
77***
78### `++slat`
80Curried slaw
82Produces a `gate` that parses a `term` `txt` to an atom of the
83odor specified by `mod`.
85Accepts
86-------
88Produces
89--------
91`mod` is a term, an atom of odor `@tas`.
93`txt` is a span, an atom of odor `@ta`.
95Source
96------
98 ++ slat |=(mod/@tas |=(txt/@ta (slaw mod txt)))
100Examples
101--------
103 > `(unit @p)`((slat %p) '~pillyt')
104 [~ ~pillyt]
105 > `(unit @ux)`((slat %ux) '0x12')
106 [~ 0x12]
107 > `(unit @if)`((slat %if) '.127.0.0.1')
108 [~ .127.0.0.1]
109 > `(unit @ta)`((slat %ta) '~.asd_a')
110 [~ ~.asd_a
114***
115### `++slav`
117Demand: parse span with input odor
119Parses a span `txt` to an atom of the odor specificed by `mod`. Crashes
120if it failes to parse.
122Accepts
123-------
125Produces
126--------
128`mod` is a term, an atom of odor `@tas`.
130`txt` is a span, an atom of odor `@ta`.
132Source
133------
135 ++ slav |=([mod/@tas txt/@ta] (need (slaw mod txt)))
137Examples
138--------
140 > `@p`(slav %p '~pillyt')
141 ~pillyt
142 > `@p`(slav %p '~pillam')
143 ! exit
144 > `@ux`(slav %ux '0x12')
145 0x12
146 > `@ux`(slav %ux '0b10')
147 ! exit
148 > `@if`(slav %if '.127.0.0.1')
149 .127.0.0.1
150 > `@if`(slav %if '.fe80.0.0.202')
151 ! exit
152 > `@ta`(slav %ta '~.asd_a')
153 ~.asd_a
154 > `@ta`(slav %ta '~~asd-a')
155 ! exit
159***
160### `++slaw`
162Parse span to input odor
164Parses a span `txt` to an atom of the odor specified by `mod`.
166Accepts
167-------
169Produces
170--------
172`mod` is a term, an atom of odor `@tas`.
174`txt` is a span, an atom of odor `@ta`.
176Source
177------
179 ++ slaw
180 ~/ %slaw
181 |= {mod/@tas txt/@ta}
182 ^- (unit @)
183 =+ con=(slay txt)
184 ?.(&(?=({$~ $$ @ @} con) =(p.p.u.con mod)) ~ [~ q.p.u.con])
187Examples
188--------
190 > `(unit @p)`(slaw %p '~pillyt')
191 [~ ~pillyt]
192 > `(unit @p)`(slaw %p '~pillam')
193 ~
194 > `(unit @ux)`(slaw %ux '0x12')
195 [~ 0x12]
196 > `(unit @ux)`(slaw %ux '0b10')
197 ~
198 > `(unit @if)`(slaw %if '.127.0.0.1')
199 [~ .127.0.0.1]
200 > `(unit @if)`(slaw %if '.fe80.0.0.202')
201 ~
202 > `(unit @ta)`(slaw %ta '~.asd_a')
203 [~ ~.asd_a]
204 > `(unit @ta)`(slaw %ta '~~asd-a')
205 ~
209***
210### `++slay`
212Parse span to coin
214Parses a span `txt` to the unit of a `++coin`.
216Accepts
217-------
219Produces
220--------
222`txt` is a `@ta`.
224Source
225------
227 ++ slay
228 |= txt/@ta ^- (unit coin)
229 =+ ^= vex
230 ?: (gth 0x7fff.ffff txt) :: XX petty cache
231 ~+ ((full nuck:so) [[1 1] (trip txt)])
232 ((full nuck:so) [[1 1] (trip txt)])
233 ?~ q.vex
234 ~
235 [~ p.u.q.vex]
236 ::
239Examples
240--------
242 > (slay '~pillyt')
243 [~ [% p=[p=~.p q=32.819]]]
244 > (slay '0x12')
245 [~ [% p=[p=~.ux q=18]]]
246 > (slay '.127.0.0.1')
247 [~ [% p=[p=~.if q=2.130.706.433]]]
248 > `@ud`.127.0.0.1
249 2.130.706.433
250 > (slay '._20_0w25_sam__')
251 [ ~
252 [ %many
253 p=~[[% p=[p=~.ud q=20]] [% p=[p=~.uw q=133]] [% p=[p=~.tas q=7.168.371]]]
254 ]
255 ]
256 > `@`%sam
257 7.168.371
258 > (slay '~0ph')
259 [~ [%blob p=[1 1]]]
260 > 0ph
261 ~ <syntax error at [1 2]>
262 > ~0ph
263 [1 1]
264 > `@uv`(jam [1 1])
265 0vph
269***
270### `++smyt`
272Render path as tank
274Renders the path `bon` as a `tank`, which is used for
275pretty-printing.
277Accepts
278-------
280Produces
281--------
283`bon` is a `++path`.
285Source
286------
288 ++ smyt :: pretty print path
289 |= bon/path ^- tank
290 :+ %rose [['/' ~] ['/' ~] ~]
291 (turn bon |=(a/@ [%leaf (trip a)]))
292 ::
294Examples
295--------
297 > (smyt %)
298 [ %rose
299 p=[p="/" q="/" r="/"]
300 q
301 ~[ [%leaf p="~zod"]
302 [%leaf p="try"]
303 [%leaf p="~2014.10.28..18.36.58..a280"]
304 ]
305 ]
306 > (smyt /as/les/top)
307 [ %rose
308 p=[p="/" q="/" r="/"]
309 q=~[[%leaf p="as"] [%leaf p="les"] [%leaf p="top"]]
310 ]
314***
315### `++spat`
317Render path as cord
319Renders a path `pax` as cord.
321Accepts
322-------
324Produces
325--------
327`pax` is a `path`.
329Source
330------
332 ++ spat |=(pax/path (crip (spud pax))) :: path to cord
334Examples
335--------
337 > (spat %)
338 '~zod/try/~2014.10.28..18.40.20..4287'
339 > (spat %/bin)
340 '~zod/try/~2014.10.28..18.41.12..3bcd/bin'
341 > (spat /as/les/top)
342 '/as/les/top'
346***
347### `++spud`
349Render path as tape
351Renders a path `pax` as tape.
353Accepts
354-------
356Produces
357--------
359`pax` is a `path`.
361Source
362------
364 ++ spud |=(pax/path ~(ram re (smyt pax))) :: path to tape
366Examples
367--------
369 > (spud %)
370 "~zod/try/~2014.10.28..18.40.46..e951"
371 > (spud %/bin)
372 "~zod/try/~2014.10.28..18.41.05..16f2/bin"
373 > (spud /as/les/top)
374 "/as/les/top"
378***
379### `++stab`
381Parse span to path
383Parsing rule. Parses a span `zep` to a static `++path`.
385Accepts
386-------
388Produces
389--------
391Source
392------
394 ++ stab :: parse cord to path
395 =+ fel=;~(pfix fas (more fas urs:ab))
396 |=(zep/@t `path`(rash zep fel))
399Examples
400--------
402 > (stab '/as/lek/tor')
403 /as/lek/tor
404 > `(pole ,@ta)`(stab '/as/lek/tor')
405 [~.as [~.lek [~.tor ~]]]
406 > (stab '~zod/arvo/~2014.10.28..18.48.41..335f/zuse')
407 ~zod/arvo/~2014.10.28..18.48.41..335f/zuse
408 > `(pole ,@ta)`(stab '~zod/arvo/~2014.10.28..18.48.41..335f/zuse')
409 [~.~zod [~.arvo [~.~2014.10.28..18.48.41..335f [~.zuse ~]]]]
410 > (stab '/a/~pillyt/pals/1')
411 /a/~pillyt/pals/1
412 > `(pole ,@ta)`(stab '/a/~pillyt/pals/1')
413 [~.a [~.~pillyt [~.pals [~.1 ~]]]]
416***