on master help sign in
Merge pull request #312 from urbit/rmariani-patch-32

Update 4d

commit0922fee0c1fbd09fc0d8b0cd95453cb123010029 authorJoshua Reagan <joshuareagan@users.noreply.github.com> dateFri 24 Aug 2018, 11:33 (8 years ago) parentdeead3352f2e0d
1 file changed+36−37
docs/hoon/library/4d.md+36−37
docs/hoon/library/4d.md+36−37
@@ -4,94 +4,93 @@ navhome: /docs/
44
55
66# 4d: parsing (tracing)
7−### `++last`
87
9−Farther trace
8+### `last`
109
11−Compares two line-column pairs, called `++hair`s, `zyc` and `naz`, producing whichever
12−is further along.
10+Further trace
1311
14−Accepts
15−-------
12+Compares two line-column pairs, `zyc` and `naz`, producing
13+whichever is further along.
1614
17−`naz` is a hair.
15+#### Accepts
1816
19−`zyc` is a hair.
17+`naz` is a `hair`.
2018
21−Produces
22−--------
19+`zyc` is a `hair`.
2320
24−a `++hair`.
21+#### Produces
2522
26−Source
27−------
23+A `hair`.
2824
29− ++ last |= {zyc/hair naz/hair} :: farther trace
25+#### Source
26+
27+ ++ last |= [zyc=hair naz=hair]
3028 ^- hair
3129 ?: =(p.zyc p.naz)
3230 ?:((gth q.zyc q.naz) zyc naz)
3331 ?:((gth p.zyc p.naz) zyc naz)
3432
3533
36−Examples
37−--------
34+#### Examples
3835
3936 > (last [1 1] [1 2])
4037 [p=1 q=2]
38+
4139 > (last [2 1] [1 2])
4240 [p=2 q=1]
41+
4342 > (last [0 0] [99 0])
4443 [p=99 q=0]
44+
4545 > (last [7 7] [7 7])
4646 [p=7 q=7]
4747
4848
4949***
50−
51−### `++lust`
50+### `lust`
5251
5352Detect newline
5453
55−Advances the `++hair` `naz` by a row if the `++char` `weq` is a newline, or by a
56−column if `weq` is any other character.
54+Advances `naz` by a row if the `weq` is a newline, or by a column if `weq` is
55+any other character.
5756
58−Accepts
59−-------
57+#### Accepts
6058
61−`weq` is a char.
59+`weq` is a `char`.
6260
63−`naz` is a hair.
61+`naz` is a `hair`.
6462
65−Produces
66−--------
63+#### Produces
6764
6865A hair.
6966
70−Source
71−------
67+#### Source
7268
73− ++ lust |= {weq/char naz/hair} :: detect newline
69+ ++ lust |= [weq=char naz=hair]
7470 ^- hair
7571 ?:(=(`@`10 weq) [+(p.naz) 1] [p.naz +(q.naz)])
7672
7773
7874
79−Examples
80−--------
75+#### Examples
8176
8277 > (lust `a` [1 1])
8378 [p=1 q=2]
79+
8480 > (lust `@t`10 [1 1])
8581 [p=2 q=1]
82+
8683 > (lust '9' [10 10])
8784 [p=10 q=11]
88− /> (roll "maze" [.(+<+ [1 1])]:lust)
85+
86+ > (roll "maze" [.(+<+ [1 1])]:lust)
8987 [1 5]
90− /> %- roll :_ [.(+<+ [1 1])]:lust
91− """
92− Sam
93− lokes
94− """
88+
89+ > %- roll :_ [.(+<+ [1 1])]:lust
90+ """
91+ Sam
92+ lokes
93+ """
9594 [2 6]
9695
9796