on b93c19b help sign in
433 lines 6.7 kB history raw
1+++
2title = "4m: Formatting Functions"
3weight = 40
4template = "doc.html"
5+++
6### `++scot`
8Render dime as cord
10Renders a dime `mol` as a cord.
12#### Accepts
14`mol` is a `++dime`.
16#### Produces
18A `cord`.
20#### Source
22```
23 ++ scot |=(mol/dime ~(rent co %$ mol))
24```
26#### Examples
28```
29 > (scot %p ~pillyt)
30 ~.~pillyt
31 > `@t`(scot %p ~pillyt)
32 '~pillyt'
33 > (scot %ux 0x12)
34 ~.0x12
35 > `@t`(scot %ux 0x12)
36 '0x12'
37 > (scot %if .127.0.0.1)
38 ~..127.0.0.1
39 > `@t`(scot %if .127.0.0.1)
40 '.127.0.0.1'
41 > (scot %ta ~.asd_a)
42 ~.~.asd_a
43 > `@t`(scot %ta ~.asd_a)
44 '~.asd_a'
45```
48---
49### `++scow`
51Render dime as tape
53Renders a dime `mol` as a tape.
55#### Accepts
57`mol` is a `++dime`.
59#### Produces
61A `tape`.
63#### Source
65```
66 ++ scow |=(mol/dime ~(rend co %$ mol))
67```
68#### Examples
70```
71 > (scow %p ~pillyt)
72 "~pillyt"
73 > (scow %ux 0x12)
74 "0x12"
75 > (scow %if .127.0.0.1)
76 ".127.0.0.1"
77 > (scow %ta ~.asd_a)
78 "~.asd_a"
79```
82---
83### `++slat`
85Curried slaw
87Produces a `gate` that parses a `term` `txt` to an atom of the
88odor specified by `mod`.
90#### Accepts
92`mod` is a term, an atom of odor `@tas`.
94`txt` is a cord, an atom of odor `@ta`.
96#### Produces
98A `gate`.
100#### Source
102```
103 ++ slat |=(mod/@tas |=(txt/@ta (slaw mod txt)))
104```
106#### Examples
108```
109 > `(unit @p)`((slat %p) '~pillyt')
110 [~ ~pillyt]
111 > `(unit @ux)`((slat %ux) '0x12')
112 [~ 0x12]
113 > `(unit @if)`((slat %if) '.127.0.0.1')
114 [~ .127.0.0.1]
115 > `(unit @ta)`((slat %ta) '~.asd_a')
116 [~ ~.asd_a
117```
120---
121### `++slav`
123Demand: parse cord with input odor
125Parses a cord `txt` to an atom of the odor specificed by `mod`.
126Crashes if it fails to parse.
128#### Accepts
130`mod` is a term, an atom of odor `@tas`.
132`txt` is a cord, an atom of odor `@ta`.
134#### Produces
136The atom of a `(unit @)` from `++slaw`, or crash.
138#### Source
140```
141 ++ slav |=([mod/@tas txt/@ta] (need (slaw mod txt)))
142```
144#### Examples
146```
147 > `@p`(slav %p '~pillyt')
148 ~pillyt
149 > `@p`(slav %p '~pillam')
150 ! exit
151 > `@ux`(slav %ux '0x12')
152 0x12
153 > `@ux`(slav %ux '0b10')
154 ! exit
155 > `@if`(slav %if '.127.0.0.1')
156 .127.0.0.1
157 > `@if`(slav %if '.fe80.0.0.202')
158 ! exit
159 > `@ta`(slav %ta '~.asd_a')
160 ~.asd_a
161 > `@ta`(slav %ta '~~asd-a')
162 ! exit
163```
165---
166### `++slaw`
168Parse cord to input odor
170Parses a cord `txt` to an atom of the odor specified by `mod`.
172#### Accepts
174`mod` is a term, an atom of odor `@tas`.
176`txt` is a cord, an atom of odor `@ta`.
178#### Produces
180A `(unit @)`.
182#### Source
184```
185 ++ slaw
186 ~/ %slaw
187 |= {mod/@tas txt/@ta}
188 ^- (unit @)
189 =+ con=(slay txt)
190 ?.(&(?=({$~ $$ @ @} con) =(p.p.u.con mod)) ~ [~ q.p.u.con])
191```
193#### Examples
195```
196 > `(unit @p)`(slaw %p '~pillyt')
197 [~ ~pillyt]
198 > `(unit @p)`(slaw %p '~pillam')
199 ~
200 > `(unit @ux)`(slaw %ux '0x12')
201 [~ 0x12]
202 > `(unit @ux)`(slaw %ux '0b10')
203 ~
204 > `(unit @if)`(slaw %if '.127.0.0.1')
205 [~ .127.0.0.1]
206 > `(unit @if)`(slaw %if '.fe80.0.0.202')
207 ~
208 > `(unit @ta)`(slaw %ta '~.asd_a')
209 [~ ~.asd_a]
210 > `(unit @ta)`(slaw %ta '~~asd-a')
211 ~
212```
215---
216### `++slay`
218Parse cord to coin
220Parses a cord `txt` to the unit of a `++coin`.
222#### Accepts
224`txt` is a `@ta`.
226#### Produces
228A `(unit coin)`.
230#### Source
232```
233 ++ slay
234 |= txt/@ta ^- (unit coin)
235 =+ ^= vex
236 ?: (gth 0x7fff.ffff txt) :: XX petty cache
237 ~+ ((full nuck:so) [[1 1] (trip txt)])
238 ((full nuck:so) [[1 1] (trip txt)])
239 ?~ q.vex
240 ~
241 [~ p.u.q.vex]
242 ::
243```
245#### Examples
247```
248 > (slay '~pillyt')
249 [~ [% p=[p=~.p q=32.819]]]
250 > (slay '0x12')
251 [~ [% p=[p=~.ux q=18]]]
252 > (slay '.127.0.0.1')
253 [~ [% p=[p=~.if q=2.130.706.433]]]
254 > `@ud`.127.0.0.1
255 2.130.706.433
256 > (slay '._20_0w25_sam__')
257 [ ~
258 [ %many
259 p=~[[% p=[p=~.ud q=20]] [% p=[p=~.uw q=133]] [% p=[p=~.tas q=7.168.371]]]
260 ]
261 ]
262 > `@`%sam
263 7.168.371
264 > (slay '~0ph')
265 [~ [%blob p=[1 1]]]
266 > 0ph
267 ~ <syntax error at [1 2]>
268 > ~0ph
269 [1 1]
270 > `@uv`(jam [1 1])
271 0vph
272```
275---
276### `++smyt`
278Render path as tank
280Renders the path `bon` as a `tank`, which is used for
281pretty-printing.
283#### Accepts
285`bon` is a `++path`.
287#### Produces
289A `tank`.
291#### Source
293```
294 ++ smyt :: pretty print path
295 |= bon/path ^- tank
296 :+ %rose [['/' ~] ['/' ~] ~]
297 (turn bon |=(a/@ [%leaf (trip a)]))
298 ::
299```
301#### Examples
303```
304 > (smyt %)
305 [ %rose
306 p=[p="/" q="/" r="/"]
307 q
308 ~[ [%leaf p="~zod"]
309 [%leaf p="try"]
310 [%leaf p="~2014.10.28..18.36.58..a280"]
311 ]
312 ]
313 > (smyt /as/les/top)
314 [ %rose
315 p=[p="/" q="/" r="/"]
316 q=~[[%leaf p="as"] [%leaf p="les"] [%leaf p="top"]]
317 ]
318```
321---
322### `++spat`
324Render path as cord
326Renders a path `pax` as cord.
328#### Accepts
330`pax` is a `path`.
332#### Produces
334A `cord`.
336#### Source
338```
339 ++ spat |=(pax/path (crip (spud pax))) :: path to cord
340```
342#### Examples
344```
345 > (spat %)
346 '~zod/try/~2014.10.28..18.40.20..4287'
347 > (spat %/bin)
348 '~zod/try/~2014.10.28..18.41.12..3bcd/bin'
349 > (spat /as/les/top)
350 '/as/les/top'
351```
354---
355### `++spud`
357Render path as tape
359Renders a path `pax` as tape.
361#### Accepts
363`pax` is a `path`.
365#### Produces
367A `tape`.
369#### Source
371```
372 ++ spud |=(pax/path ~(ram re (smyt pax))) :: path to tape
373```
375#### Examples
377```
378 > (spud %)
379 "~zod/try/~2014.10.28..18.40.46..e951"
380 > (spud %/bin)
381 "~zod/try/~2014.10.28..18.41.05..16f2/bin"
382 > (spud /as/les/top)
383 "/as/les/top"
384```
387---
388### `++stab`
390Parse cord to path
392Parsing rule. Parses a cord `zep` to a static `++path`.
393Crashes if it fails to parse.
395#### Accepts
397`zep` is a `@t`.
399#### Produces
401A `path`, or crash.
403#### Source
405```
406 ++ stab :: parse cord to path
407 =+ fel=;~(pfix fas (more fas urs:ab))
408 |=(zep/@t `path`(rash zep fel))
409```
411#### Examples
413```
414 > (stab '/as/lek/tor')
415 /as/lek/tor
417 > `(pole ,@ta)`(stab '/as/lek/tor')
418 [~.as [~.lek [~.tor ~]]]
420 > (stab '~zod/arvo/~2014.10.28..18.48.41..335f/zuse')
421 ~zod/arvo/~2014.10.28..18.48.41..335f/zuse
423 > `(pole ,@ta)`(stab '~zod/arvo/~2014.10.28..18.48.41..335f/zuse')
424 [~.~zod [~.arvo [~.~2014.10.28..18.48.41..335f [~.zuse ~]]]]
426 > (stab '/a/~pillyt/pals/1')
427 /a/~pillyt/pals/1
429 > `(pole ,@ta)`(stab '/a/~pillyt/pals/1')
430 [~.a [~.~pillyt [~.pals [~.1 ~]]]]
431```
433---