on 4fdc19d help sign in
100 lines 1.2 kB history raw
1+++
2title = "4d: Parsing (Tracing)"
3weight = 31
4template = "doc.html"
5+++
7## `++last`
9Further trace
11Compares two line-column pairs, `zyc` and `naz`, producing
12whichever is further along.
14#### Accepts
16`zyc` is a `hair`.
18`naz` is a `hair`.
20#### Produces
22A `hair`.
24#### Source
26```hoon
27++ last |= [zyc=hair naz=hair]
28 ^- hair
29 ?: =(p.zyc p.naz)
30 ?:((gth q.zyc q.naz) zyc naz)
31 ?:((gth p.zyc p.naz) zyc naz)
32```
34#### Examples
36```
37> (last [1 1] [1 2])
38[p=1 q=2]
40> (last [2 1] [1 2])
41[p=2 q=1]
43> (last [0 0] [99 0])
44[p=99 q=0]
46> (last [7 7] [7 7])
47[p=7 q=7]
48```
50---
52## `++lust`
54Detect newline
56Advances `naz` by a row if the `weq` is a newline, or by a column if `weq` is
57any other character.
59#### Accepts
61`weq` is a `char`.
63`naz` is a `hair`.
65#### Produces
67A `hair`.
69#### Source
71```hoon
72++ lust |= [weq=char naz=hair]
73 ^- hair
74 ?:(=(`@`10 weq) [+(p.naz) 1] [p.naz +(q.naz)])
75```
77#### Examples
79```
80> (lust `a` [1 1])
81[p=1 q=2]
83> (lust `@t`10 [1 1])
84[p=2 q=1]
86> (lust '9' [10 10])
87[p=10 q=11]
89> (roll "maze" [.(+<+ [1 1])]:lust)
90[1 5]
92> %- roll :_ [.(+<+ [1 1])]:lust
93 """
94 Sam
95 lokes
96 """
97[2 6]
98```
100---