4d: Parsing (Tracing)

++last

Further trace

Compares two line-column pairs, zyc and naz, producing whichever is further along.

Accepts

zyc is a hair.

naz is a hair.

Produces

A hair.

Source

++ last |= [zyc=hair naz=hair]
^- hair
?: =(p.zyc p.naz)
?:((gth q.zyc q.naz) zyc naz)
?:((gth p.zyc p.naz) zyc naz)

Examples

> (last [1 1] [1 2])
[p=1 q=2]
> (last [2 1] [1 2])
[p=2 q=1]
> (last [0 0] [99 0])
[p=99 q=0]
> (last [7 7] [7 7])
[p=7 q=7]

++lust

Detect newline

Advances naz by a row if the weq is a newline, or by a column if weq is any other character.

Accepts

weq is a char.

naz is a hair.

Produces

A hair.

Source

++ lust |= [weq=char naz=hair]
^- hair
?:(=(`@`10 weq) [+(p.naz) 1] [p.naz +(q.naz)])

Examples

> (lust `a` [1 1])
[p=1 q=2]
> (lust `@t`10 [1 1])
[p=2 q=1]
> (lust '9' [10 10])
[p=10 q=11]
> (roll "maze" [.(+<+ [1 1])]:lust)
[1 5]
> %- roll :_ [.(+<+ [1 1])]:lust
"""
Sam
lokes
"""
[2 6]

Edit this page on GitHub

Last modified October 8, 2023