on 6d45ede help sign in
421 lines 6.5 kB history raw
1---
2navhome: /docs
3---
6# 4m: formatting functions
7### `++scot`
9Render dime as cord
11Renders a dime `mol` as a cord.
13Accepts
14-------
16Produces
17--------
19`mol` is a `++dime`.
21Source
22------
24 ++ scot |=(mol/dime ~(rent co %$ mol))
26Examples
27--------
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'
48***
49### `++scow`
51Render dime as tape
53Renders `mol` as a tape.
55Accepts
56-------
58Produces
59--------
61`mol` is a `++dime`.
63Source
64------
66 ++ scow |=(mol/dime ~(rend co %$ mol))
68Examples
69--------
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"
82***
83### `++slat`
85Curried slaw
87Produces a `gate` that parses a `term` `txt` to an atom of the
88odor specified by `mod`.
90Accepts
91-------
93Produces
94--------
96`mod` is a term, an atom of odor `@tas`.
98`txt` is a span, an atom of odor `@ta`.
100Source
101------
103 ++ slat |=(mod/@tas |=(txt/@ta (slaw mod txt)))
105Examples
106--------
108 > `(unit @p)`((slat %p) '~pillyt')
109 [~ ~pillyt]
110 > `(unit @ux)`((slat %ux) '0x12')
111 [~ 0x12]
112 > `(unit @if)`((slat %if) '.127.0.0.1')
113 [~ .127.0.0.1]
114 > `(unit @ta)`((slat %ta) '~.asd_a')
115 [~ ~.asd_a
119***
120### `++slav`
122Demand: parse span with input odor
124Parses a span `txt` to an atom of the odor specificed by `mod`. Crashes
125if it failes to parse.
127Accepts
128-------
130Produces
131--------
133`mod` is a term, an atom of odor `@tas`.
135`txt` is a span, an atom of odor `@ta`.
137Source
138------
140 ++ slav |=([mod/@tas txt/@ta] (need (slaw mod txt)))
142Examples
143--------
145 > `@p`(slav %p '~pillyt')
146 ~pillyt
147 > `@p`(slav %p '~pillam')
148 ! exit
149 > `@ux`(slav %ux '0x12')
150 0x12
151 > `@ux`(slav %ux '0b10')
152 ! exit
153 > `@if`(slav %if '.127.0.0.1')
154 .127.0.0.1
155 > `@if`(slav %if '.fe80.0.0.202')
156 ! exit
157 > `@ta`(slav %ta '~.asd_a')
158 ~.asd_a
159 > `@ta`(slav %ta '~~asd-a')
160 ! exit
164***
165### `++slaw`
167Parse span to input odor
169Parses a span `txt` to an atom of the odor specified by `mod`.
171Accepts
172-------
174Produces
175--------
177`mod` is a term, an atom of odor `@tas`.
179`txt` is a span, an atom of odor `@ta`.
181Source
182------
184 ++ slaw
185 ~/ %slaw
186 |= {mod/@tas txt/@ta}
187 ^- (unit @)
188 =+ con=(slay txt)
189 ?.(&(?=({$~ $$ @ @} con) =(p.p.u.con mod)) ~ [~ q.p.u.con])
192Examples
193--------
195 > `(unit @p)`(slaw %p '~pillyt')
196 [~ ~pillyt]
197 > `(unit @p)`(slaw %p '~pillam')
198 ~
199 > `(unit @ux)`(slaw %ux '0x12')
200 [~ 0x12]
201 > `(unit @ux)`(slaw %ux '0b10')
202 ~
203 > `(unit @if)`(slaw %if '.127.0.0.1')
204 [~ .127.0.0.1]
205 > `(unit @if)`(slaw %if '.fe80.0.0.202')
206 ~
207 > `(unit @ta)`(slaw %ta '~.asd_a')
208 [~ ~.asd_a]
209 > `(unit @ta)`(slaw %ta '~~asd-a')
210 ~
214***
215### `++slay`
217Parse span to coin
219Parses a span `txt` to the unit of a `++coin`.
221Accepts
222-------
224Produces
225--------
227`txt` is a `@ta`.
229Source
230------
232 ++ slay
233 |= txt/@ta ^- (unit coin)
234 =+ ^= vex
235 ?: (gth 0x7fff.ffff txt) :: XX petty cache
236 ~+ ((full nuck:so) [[1 1] (trip txt)])
237 ((full nuck:so) [[1 1] (trip txt)])
238 ?~ q.vex
239 ~
240 [~ p.u.q.vex]
241 ::
244Examples
245--------
247 > (slay '~pillyt')
248 [~ [% p=[p=~.p q=32.819]]]
249 > (slay '0x12')
250 [~ [% p=[p=~.ux q=18]]]
251 > (slay '.127.0.0.1')
252 [~ [% p=[p=~.if q=2.130.706.433]]]
253 > `@ud`.127.0.0.1
254 2.130.706.433
255 > (slay '._20_0w25_sam__')
256 [ ~
257 [ %many
258 p=~[[% p=[p=~.ud q=20]] [% p=[p=~.uw q=133]] [% p=[p=~.tas q=7.168.371]]]
259 ]
260 ]
261 > `@`%sam
262 7.168.371
263 > (slay '~0ph')
264 [~ [%blob p=[1 1]]]
265 > 0ph
266 ~ <syntax error at [1 2]>
267 > ~0ph
268 [1 1]
269 > `@uv`(jam [1 1])
270 0vph
274***
275### `++smyt`
277Render path as tank
279Renders the path `bon` as a `tank`, which is used for
280pretty-printing.
282Accepts
283-------
285Produces
286--------
288`bon` is a `++path`.
290Source
291------
293 ++ smyt :: pretty print path
294 |= bon/path ^- tank
295 :+ %rose [['/' ~] ['/' ~] ~]
296 (turn bon |=(a/@ [%leaf (trip a)]))
297 ::
299Examples
300--------
302 > (smyt %)
303 [ %rose
304 p=[p="/" q="/" r="/"]
305 q
306 ~[ [%leaf p="~zod"]
307 [%leaf p="try"]
308 [%leaf p="~2014.10.28..18.36.58..a280"]
309 ]
310 ]
311 > (smyt /as/les/top)
312 [ %rose
313 p=[p="/" q="/" r="/"]
314 q=~[[%leaf p="as"] [%leaf p="les"] [%leaf p="top"]]
315 ]
319***
320### `++spat`
322Render path as cord
324Renders a path `pax` as cord.
326Accepts
327-------
329Produces
330--------
332`pax` is a `path`.
334Source
335------
337 ++ spat |=(pax/path (crip (spud pax))) :: path to cord
339Examples
340--------
342 > (spat %)
343 '~zod/try/~2014.10.28..18.40.20..4287'
344 > (spat %/bin)
345 '~zod/try/~2014.10.28..18.41.12..3bcd/bin'
346 > (spat /as/les/top)
347 '/as/les/top'
351***
352### `++spud`
354Render path as tape
356Renders a path `pax` as tape.
358Accepts
359-------
361Produces
362--------
364`pax` is a `path`.
366Source
367------
369 ++ spud |=(pax/path ~(ram re (smyt pax))) :: path to tape
371Examples
372--------
374 > (spud %)
375 "~zod/try/~2014.10.28..18.40.46..e951"
376 > (spud %/bin)
377 "~zod/try/~2014.10.28..18.41.05..16f2/bin"
378 > (spud /as/les/top)
379 "/as/les/top"
383***
384### `++stab`
386Parse span to path
388Parsing rule. Parses a span `zep` to a static `++path`.
390Accepts
391-------
393Produces
394--------
396Source
397------
399 ++ stab :: parse cord to path
400 =+ fel=;~(pfix fas (more fas urs:ab))
401 |=(zep/@t `path`(rash zep fel))
404Examples
405--------
407 > (stab '/as/lek/tor')
408 /as/lek/tor
409 > `(pole ,@ta)`(stab '/as/lek/tor')
410 [~.as [~.lek [~.tor ~]]]
411 > (stab '~zod/arvo/~2014.10.28..18.48.41..335f/zuse')
412 ~zod/arvo/~2014.10.28..18.48.41..335f/zuse
413 > `(pole ,@ta)`(stab '~zod/arvo/~2014.10.28..18.48.41..335f/zuse')
414 [~.~zod [~.arvo [~.~2014.10.28..18.48.41..335f [~.zuse ~]]]]
415 > (stab '/a/~pillyt/pals/1')
416 /a/~pillyt/pals/1
417 > `(pole ,@ta)`(stab '/a/~pillyt/pals/1')
418 [~.a [~.~pillyt [~.pals [~.1 ~]]]]
421***