on c19bc7a help sign in
437 lines 6.8 kB history raw
1:- :~ navhome/'/docs/'
2 sort/'40'
3 title/'4m: Formatting Functions'
4 ==
6;>
8# 4m: formatting functions
10### `++scot`
12Render dime as cord
14Renders a dime `mol` as a cord.
16#### Accepts
18`mol` is a `++dime`.
20#### Produces
22A `cord`.
24#### Source
26```
27 ++ scot |=(mol/dime ~(rent co %$ mol))
28```
30#### Examples
32```
33 > (scot %p ~pillyt)
34 ~.~pillyt
35 > `@t`(scot %p ~pillyt)
36 '~pillyt'
37 > (scot %ux 0x12)
38 ~.0x12
39 > `@t`(scot %ux 0x12)
40 '0x12'
41 > (scot %if .127.0.0.1)
42 ~..127.0.0.1
43 > `@t`(scot %if .127.0.0.1)
44 '.127.0.0.1'
45 > (scot %ta ~.asd_a)
46 ~.~.asd_a
47 > `@t`(scot %ta ~.asd_a)
48 '~.asd_a'
49```
52---
53### `++scow`
55Render dime as tape
57Renders a dime `mol` as a tape.
59#### Accepts
61`mol` is a `++dime`.
63#### Produces
65A `tape`.
67#### Source
69```
70 ++ scow |=(mol/dime ~(rend co %$ mol))
71```
72#### Examples
74```
75 > (scow %p ~pillyt)
76 "~pillyt"
77 > (scow %ux 0x12)
78 "0x12"
79 > (scow %if .127.0.0.1)
80 ".127.0.0.1"
81 > (scow %ta ~.asd_a)
82 "~.asd_a"
83```
86---
87### `++slat`
89Curried slaw
91Produces a `gate` that parses a `term` `txt` to an atom of the
92odor specified by `mod`.
94#### Accepts
96`mod` is a term, an atom of odor `@tas`.
98`txt` is a cord, an atom of odor `@ta`.
100#### Produces
102A `gate`.
104#### Source
106```
107 ++ slat |=(mod/@tas |=(txt/@ta (slaw mod txt)))
108```
110#### Examples
112```
113 > `(unit @p)`((slat %p) '~pillyt')
114 [~ ~pillyt]
115 > `(unit @ux)`((slat %ux) '0x12')
116 [~ 0x12]
117 > `(unit @if)`((slat %if) '.127.0.0.1')
118 [~ .127.0.0.1]
119 > `(unit @ta)`((slat %ta) '~.asd_a')
120 [~ ~.asd_a
121```
124---
125### `++slav`
127Demand: parse cord with input odor
129Parses a cord `txt` to an atom of the odor specificed by `mod`.
130Crashes if it fails to parse.
132#### Accepts
134`mod` is a term, an atom of odor `@tas`.
136`txt` is a cord, an atom of odor `@ta`.
138#### Produces
140The atom of a `(unit @)` from `++slaw`, or crash.
142#### Source
144```
145 ++ slav |=([mod/@tas txt/@ta] (need (slaw mod txt)))
146```
148#### Examples
150```
151 > `@p`(slav %p '~pillyt')
152 ~pillyt
153 > `@p`(slav %p '~pillam')
154 ! exit
155 > `@ux`(slav %ux '0x12')
156 0x12
157 > `@ux`(slav %ux '0b10')
158 ! exit
159 > `@if`(slav %if '.127.0.0.1')
160 .127.0.0.1
161 > `@if`(slav %if '.fe80.0.0.202')
162 ! exit
163 > `@ta`(slav %ta '~.asd_a')
164 ~.asd_a
165 > `@ta`(slav %ta '~~asd-a')
166 ! exit
167```
169---
170### `++slaw`
172Parse cord to input odor
174Parses a cord `txt` to an atom of the odor specified by `mod`.
176#### Accepts
178`mod` is a term, an atom of odor `@tas`.
180`txt` is a cord, an atom of odor `@ta`.
182#### Produces
184A `(unit @)`.
186#### Source
188```
189 ++ slaw
190 ~/ %slaw
191 |= {mod/@tas txt/@ta}
192 ^- (unit @)
193 =+ con=(slay txt)
194 ?.(&(?=({$~ $$ @ @} con) =(p.p.u.con mod)) ~ [~ q.p.u.con])
195```
197#### Examples
199```
200 > `(unit @p)`(slaw %p '~pillyt')
201 [~ ~pillyt]
202 > `(unit @p)`(slaw %p '~pillam')
203 ~
204 > `(unit @ux)`(slaw %ux '0x12')
205 [~ 0x12]
206 > `(unit @ux)`(slaw %ux '0b10')
207 ~
208 > `(unit @if)`(slaw %if '.127.0.0.1')
209 [~ .127.0.0.1]
210 > `(unit @if)`(slaw %if '.fe80.0.0.202')
211 ~
212 > `(unit @ta)`(slaw %ta '~.asd_a')
213 [~ ~.asd_a]
214 > `(unit @ta)`(slaw %ta '~~asd-a')
215 ~
216```
219---
220### `++slay`
222Parse cord to coin
224Parses a cord `txt` to the unit of a `++coin`.
226#### Accepts
228`txt` is a `@ta`.
230#### Produces
232A `(unit coin)`.
234#### Source
236```
237 ++ slay
238 |= txt/@ta ^- (unit coin)
239 =+ ^= vex
240 ?: (gth 0x7fff.ffff txt) :: XX petty cache
241 ~+ ((full nuck:so) [[1 1] (trip txt)])
242 ((full nuck:so) [[1 1] (trip txt)])
243 ?~ q.vex
244 ~
245 [~ p.u.q.vex]
246 ::
247```
249#### Examples
251```
252 > (slay '~pillyt')
253 [~ [% p=[p=~.p q=32.819]]]
254 > (slay '0x12')
255 [~ [% p=[p=~.ux q=18]]]
256 > (slay '.127.0.0.1')
257 [~ [% p=[p=~.if q=2.130.706.433]]]
258 > `@ud`.127.0.0.1
259 2.130.706.433
260 > (slay '._20_0w25_sam__')
261 [ ~
262 [ %many
263 p=~[[% p=[p=~.ud q=20]] [% p=[p=~.uw q=133]] [% p=[p=~.tas q=7.168.371]]]
264 ]
265 ]
266 > `@`%sam
267 7.168.371
268 > (slay '~0ph')
269 [~ [%blob p=[1 1]]]
270 > 0ph
271 ~ <syntax error at [1 2]>
272 > ~0ph
273 [1 1]
274 > `@uv`(jam [1 1])
275 0vph
276```
279---
280### `++smyt`
282Render path as tank
284Renders the path `bon` as a `tank`, which is used for
285pretty-printing.
287#### Accepts
289`bon` is a `++path`.
291#### Produces
293A `tank`.
295#### Source
297```
298 ++ smyt :: pretty print path
299 |= bon/path ^- tank
300 :+ %rose [['/' ~] ['/' ~] ~]
301 (turn bon |=(a/@ [%leaf (trip a)]))
302 ::
303```
305#### Examples
307```
308 > (smyt %)
309 [ %rose
310 p=[p="/" q="/" r="/"]
311 q
312 ~[ [%leaf p="~zod"]
313 [%leaf p="try"]
314 [%leaf p="~2014.10.28..18.36.58..a280"]
315 ]
316 ]
317 > (smyt /as/les/top)
318 [ %rose
319 p=[p="/" q="/" r="/"]
320 q=~[[%leaf p="as"] [%leaf p="les"] [%leaf p="top"]]
321 ]
322```
325---
326### `++spat`
328Render path as cord
330Renders a path `pax` as cord.
332#### Accepts
334`pax` is a `path`.
336#### Produces
338A `cord`.
340#### Source
342```
343 ++ spat |=(pax/path (crip (spud pax))) :: path to cord
344```
346#### Examples
348```
349 > (spat %)
350 '~zod/try/~2014.10.28..18.40.20..4287'
351 > (spat %/bin)
352 '~zod/try/~2014.10.28..18.41.12..3bcd/bin'
353 > (spat /as/les/top)
354 '/as/les/top'
355```
358---
359### `++spud`
361Render path as tape
363Renders a path `pax` as tape.
365#### Accepts
367`pax` is a `path`.
369#### Produces
371A `tape`.
373#### Source
375```
376 ++ spud |=(pax/path ~(ram re (smyt pax))) :: path to tape
377```
379#### Examples
381```
382 > (spud %)
383 "~zod/try/~2014.10.28..18.40.46..e951"
384 > (spud %/bin)
385 "~zod/try/~2014.10.28..18.41.05..16f2/bin"
386 > (spud /as/les/top)
387 "/as/les/top"
388```
391---
392### `++stab`
394Parse cord to path
396Parsing rule. Parses a cord `zep` to a static `++path`.
397Crashes if it fails to parse.
399#### Accepts
401`zep` is a `@t`.
403#### Produces
405A `path`, or crash.
407#### Source
409```
410 ++ stab :: parse cord to path
411 =+ fel=;~(pfix fas (more fas urs:ab))
412 |=(zep/@t `path`(rash zep fel))
413```
415#### Examples
417```
418 > (stab '/as/lek/tor')
419 /as/lek/tor
421 > `(pole ,@ta)`(stab '/as/lek/tor')
422 [~.as [~.lek [~.tor ~]]]
424 > (stab '~zod/arvo/~2014.10.28..18.48.41..335f/zuse')
425 ~zod/arvo/~2014.10.28..18.48.41..335f/zuse
427 > `(pole ,@ta)`(stab '~zod/arvo/~2014.10.28..18.48.41..335f/zuse')
428 [~.~zod [~.arvo [~.~2014.10.28..18.48.41..335f [~.zuse ~]]]]
430 > (stab '/a/~pillyt/pals/1')
431 /a/~pillyt/pals/1
433 > `(pole ,@ta)`(stab '/a/~pillyt/pals/1')
434 [~.a [~.~pillyt [~.pals [~.1 ~]]]]
435```
437---