on 140ac0e help sign in
93 lines 1.4 kB history raw
1# 4d: parsing (tracing)
2### `++last`
4Farther trace
6Compares two line-column pairs, called `++hair`s, `zyc` and `naz`, producing whichever
7is further along.
9Accepts
10-------
12`naz` is a hair.
14`zyc` is a hair.
16Produces
17--------
19a `++hair`.
21Source
22------
24 ++ last |= {zyc/hair naz/hair} :: farther trace
25 ^- hair
26 ?: =(p.zyc p.naz)
27 ?:((gth q.zyc q.naz) zyc naz)
28 ?:((gth p.zyc p.naz) zyc naz)
31Examples
32--------
34 > (last [1 1] [1 2])
35 [p=1 q=2]
36 > (last [2 1] [1 2])
37 [p=2 q=1]
38 > (last [0 0] [99 0])
39 [p=99 q=0]
40 > (last [7 7] [7 7])
41 [p=7 q=7]
44***
46### `++lust`
48Detect newline
50Advances the `++hair` `naz` by a row if the `++char` `weq` is a newline, or by a
51column if `weq` is any other character.
53Accepts
54-------
56`weq` is a char.
58`naz` is a hair.
60Produces
61--------
63A hair.
65Source
66------
68 ++ lust |= {weq/char naz/hair} :: detect newline
69 ^- hair
70 ?:(=(`@`10 weq) [+(p.naz) 1] [p.naz +(q.naz)])
74Examples
75--------
77 > (lust `a` [1 1])
78 [p=1 q=2]
79 > (lust `@t`10 [1 1])
80 [p=2 q=1]
81 > (lust '9' [10 10])
82 [p=10 q=11]
83 /> (roll "maze" [.(+<+ [1 1])]:lust)
84 [1 5]
85 /> %- roll :_ [.(+<+ [1 1])]:lust
86 """
87 Sam
88 lokes
89 """
90 [2 6]
93***