on 492ae2f help sign in
60 lines 1.4 kB history raw
1### `++iny`
3Indentation block
5Apply `++rule` to indented block starting at current column number, omitting
6the leading whitespace.
8Accepts
9-------
11`sef` is a `++rule`
13Produces
14--------
16A `++rule`.
18Source
19------
21 ++ inde |* sef/rule :: indentation block
22 |= nail ^+ (sef)
23 =+ [har tap]=[p q]:+<
24 =+ lev=(fil 3 (dec q.har) ' ')
25 =+ eol=(just `@t`10)
26 =+ =- roq=((star ;~(pose prn ;~(sfix eol (jest lev)) -)) har tap)
27 ;~(simu ;~(plug eol eol) eol)
28 ?~ q.roq roq
29 =+ vex=(sef har(q 1) p.u.q.roq)
30 =+ fur=p.vex(q (add (dec q.har) q.p.vex))
31 ?~ q.vex vex(p fur)
32 =- vex(p fur, u.q -)
33 :+ &3.vex
34 &4.vex(q.p (add (dec q.har) q.p.&4.vex))
35 =+ res=|4.vex
36 |- ?~ res |4.roq
37 ?. =(10 -.res) [-.res $(res +.res)]
38 (welp [`@t`10 (trip lev)] $(res +.res))
39 ::
41Examples
42--------
44 ~zod/try=> (scan "abc" (iny (star ;~(pose prn (just `@`10)))))
45 "abc"
46 ~zod/try=> (scan "abc" (star ;~(pose prn (just `@`10))))
47 "abc"
48 ~zod/try=> (scan " abc\0ade" ;~(pfix ace ace (star ;~(pose prn (just `@`10)))))
49 "abc
50 de"
51 ~zod/try=> (scan " abc\0ade" ;~(pfix ace ace (iny (star ;~(pose prn (just `@`10))))))
52 ! {1 6}
53 ! exit
54 ~zod/try=> (scan " abc\0a de" ;~(pfix ace ace (iny (star ;~(pose prn (just `@`10))))))
55 "abc
56 de"
60***