on master help sign in
Update 4d
52f2e0drmariani
docs/hoon/library/4d.md+36−37
@@ -4,94 +4,93 @@ navhome: /docs/
4
4
5
5
6# 4d: parsing (tracing)
6# 4d: parsing (tracing)
7−### `++last`
8
7
9−Farther trace
8+### `last`
10
9
11−Compares two line-column pairs, called `++hair`s, `zyc` and `naz`, producing whichever
10+Further trace
12−is further along.
13
11
14−Accepts
12+Compares two line-column pairs, `zyc` and `naz`, producing
15−-------
13+whichever is further along.
16
14
17−`naz` is a hair.
15+#### Accepts
18
16
19−`zyc` is a hair.
17+`naz` is a `hair`.
20
18
21−Produces
19+`zyc` is a `hair`.
22−--------
23
20
24−a `++hair`.
21+#### Produces
25
22
26−Source
23+A `hair`.
27−------
28
24
25+#### Source
26+
29− ++ last |= {zyc/hair naz/hair} :: farther trace
27+ ++ last |= [zyc=hair naz=hair]
30 ^- hair
28 ^- hair
31 ?: =(p.zyc p.naz)
29 ?: =(p.zyc p.naz)
32 ?:((gth q.zyc q.naz) zyc naz)
30 ?:((gth q.zyc q.naz) zyc naz)
33 ?:((gth p.zyc p.naz) zyc naz)
31 ?:((gth p.zyc p.naz) zyc naz)
34
32
35
33
36−Examples
34+#### Examples
37−--------
38
35
39 > (last [1 1] [1 2])
36 > (last [1 1] [1 2])
40 [p=1 q=2]
37 [p=1 q=2]
38+
41 > (last [2 1] [1 2])
39 > (last [2 1] [1 2])
42 [p=2 q=1]
40 [p=2 q=1]
41+
43 > (last [0 0] [99 0])
42 > (last [0 0] [99 0])
44 [p=99 q=0]
43 [p=99 q=0]
44+
45 > (last [7 7] [7 7])
45 > (last [7 7] [7 7])
46 [p=7 q=7]
46 [p=7 q=7]
47
47
48
48
49***
49***
50−
51−### `++lust`
50+### `lust`
52
51
53Detect newline
52Detect newline
54
53
55−Advances the `++hair` `naz` by a row if the `++char` `weq` is a newline, or by a
54+Advances `naz` by a row if the `weq` is a newline, or by a column if `weq` is
56−column if `weq` is any other character.
55+any other character.
57
56
58−Accepts
57+#### Accepts
59−-------
60
58
61−`weq` is a char.
59+`weq` is a `char`.
62
60
63−`naz` is a hair.
61+`naz` is a `hair`.
64
62
65−Produces
63+#### Produces
66−--------
67
64
68A hair.
65A hair.
69
66
70−Source
67+#### Source
71−------
72
68
73− ++ lust |= {weq/char naz/hair} :: detect newline
69+ ++ lust |= [weq=char naz=hair]
74 ^- hair
70 ^- hair
75 ?:(=(`@`10 weq) [+(p.naz) 1] [p.naz +(q.naz)])
71 ?:(=(`@`10 weq) [+(p.naz) 1] [p.naz +(q.naz)])
76
72
77
73
78
74
79−Examples
75+#### Examples
80−--------
81
76
82 > (lust `a` [1 1])
77 > (lust `a` [1 1])
83 [p=1 q=2]
78 [p=1 q=2]
79+
84 > (lust `@t`10 [1 1])
80 > (lust `@t`10 [1 1])
85 [p=2 q=1]
81 [p=2 q=1]
82+
86 > (lust '9' [10 10])
83 > (lust '9' [10 10])
87 [p=10 q=11]
84 [p=10 q=11]
85+
88− /> (roll "maze" [.(+<+ [1 1])]:lust)
86+ > (roll "maze" [.(+<+ [1 1])]:lust)
89 [1 5]
87 [1 5]
88+
90− /> %- roll :_ [.(+<+ [1 1])]:lust
89+ > %- roll :_ [.(+<+ [1 1])]:lust
91− """
90+ """
92− Sam
91+ Sam
93− lokes
92+ lokes
94− """
93+ """
95 [2 6]
94 [2 6]
96
95
97
96