on c19bc7a help sign in
104 lines 1.4 kB history raw
1:- :~ navhome/'/docs/'
2 sort/'31'
3 title/'4d: Parsing (Tracing)'
4 ==
6;>
9# 4d: parsing (tracing)
11### `last`
13Further trace
15Compares two line-column pairs, `zyc` and `naz`, producing
16whichever is further along.
18#### Accepts
20`naz` is a `hair`.
22`zyc` is a `hair`.
24#### Produces
26A `hair`.
28#### Source
30```
31 ++ last |= [zyc=hair naz=hair]
32 ^- hair
33 ?: =(p.zyc p.naz)
34 ?:((gth q.zyc q.naz) zyc naz)
35 ?:((gth p.zyc p.naz) zyc naz)
36```
38#### Examples
40```
41 > (last [1 1] [1 2])
42 [p=1 q=2]
44 > (last [2 1] [1 2])
45 [p=2 q=1]
47 > (last [0 0] [99 0])
48 [p=99 q=0]
50 > (last [7 7] [7 7])
51 [p=7 q=7]
52```
54***
55### `lust`
57Detect newline
59Advances `naz` by a row if the `weq` is a newline, or by a column if `weq` is
60any other character.
62#### Accepts
64`weq` is a `char`.
66`naz` is a `hair`.
68#### Produces
70A hair.
72#### Source
74```
75 ++ lust |= [weq=char naz=hair]
76 ^- hair
77 ?:(=(`@`10 weq) [+(p.naz) 1] [p.naz +(q.naz)])
78```
81#### Examples
83```
84 > (lust `a` [1 1])
85 [p=1 q=2]
87 > (lust `@t`10 [1 1])
88 [p=2 q=1]
90 > (lust '9' [10 10])
91 [p=10 q=11]
93 > (roll "maze" [.(+<+ [1 1])]:lust)
94 [1 5]
96 > %- roll :_ [.(+<+ [1 1])]:lust
97 """
98 Sam
99 lokes
100 """
101 [2 6]
102```
104***