text.bend checks
raw source on the hub · import bend-kit-text@0.2.1.1/text.bend as Text
Text utilities: Myers diff with unified output, Levenshtein distance, and word wrap by display width.
3 imports
import Base import bend-kit-unicode@0.1.0.0/unicode.bend as Unicode import bend-kit-tty@0.1.0.1/text.bend as Tty
Types
type Edit source · line 9 · raw
@-A:Data -> Data
Same pairs an old item with the new item it matched; before keeps old items, after keeps new ones.
Same@-A:Data -> @old:A -> @new:A -> Edit<A>
Del@-A:Data -> @old:A -> Edit<A>
Ins@-A:Data -> @new:A -> Edit<A>
type Move source · line 14 · raw
Data
MSameMove
MDelMove
MInsMove
type Ctx source · line 73 · raw
@-A:Data -> Type
The items, and the forward and reverse frontiers: v[off + k] is the furthest x on diagonal k = x - y.
Ctx@-A:Data -> @a:Array<A> -> @b:Array<A> -> @vf:Array<U32> -> @vb:Array<U32> -> Ctx<A>
type Geo source · line 77 · raw
Data
A segment of n items of a from os, and m items of b from ns. off centres the frontiers.
Geo@os:U32 -> @ns:U32 -> @n:U32 -> @m:U32 -> @off:U32 -> Geo
type Pt source · line 80 · raw
Data
Pt@x:U32 -> @y:U32 -> Pt
type Job source · line 243 · raw
Data
A segment still to diff, or moves ready to emit.
JSolve@os:U32 -> @oe:U32 -> @ns:U32 -> @ne:U32 -> Job
JEmit@ms:List<&2, Move> -> Job
type Row source · line 471 · raw
Data
A Gap is a Same line outside every hunk. dold and dnew count the old and new lines a row consumes.
GapRow
Line@text:String -> @dold:U32 -> @dnew:U32 -> Row
type Hunk source · line 487 · raw
Data
Hunk@o:U32 -> @n:U32 -> @ol:U32 -> @nl:U32 -> @body:List<&2, String> -> Hunk
type Wr source · line 650 · raw
Data
The finished lines, newest first, and the line being built.
Wr@out:List<&2, String> -> @cur:Maybe<&2, String> -> Wr
type Fw source · line 792 · raw
Data
The finished lines, newest first; the words of the open line, newest first; its width; and its last code point.
Fw@out:List<&2, String> -> @cur:List<&2, String> -> @cw:U32 -> @end:U32 -> Fw
Definitions
def before source · line 19 · raw
@-A:Data -> @es:List<&2, Edit<A>> -> List<&2, A>
def after source · line 30 · raw
@-A:Data -> @es:List<&2, Edit<A>> -> List<&2, A>
def walk.ins source · line 41 · raw
@-A:Data -> @b:List<&2, A> -> List<&2, Edit<A>>
def walk.rest source · line 48 · raw
@-A:Data -> @a:List<&2, A> -> @b:List<&2, A> -> List<&2, Edit<A>>
def walk source · line 57 · raw
@-A:Data -> @ms:List<&2, Move> -> @a:List<&2, A> -> @b:List<&2, A> -> List<&2, Edit<A>>
Replays moves over a and b. A move that does not fit is skipped, and leftovers become Del then Ins, so before and after give a and b back for any moves.
def geo.os source · line 83 · raw
@+g:Geo -> U32
def geo.ns source · line 88 · raw
@+g:Geo -> U32
def geo.n source · line 93 · raw
@+g:Geo -> U32
def geo.m source · line 98 · raw
@+g:Geo -> U32
def geo.off source · line 103 · raw
@+g:Geo -> U32
def changes source · line 247 · raw
@+dels:U32 -> @+ins:U32 -> List<&2, Move>
def canon.flush source · line 313 · raw
@d:Nat -> @i:Nat -> @rest:List<&2, Move> -> List<&2, Move>
def canon source · line 317 · raw
@ms:List<&2, Move> -> @+d:Nat -> @+i:Nat -> List<&2, Move>
Each run of changes puts its deletes first, as diff does.
def lines.push source · line 401 · raw
@c:Char -> @ls:List<&2, String> -> List<&2, String>
def lines.pick source · line 408 · raw
@nl:Bool -> @c:Char -> @ls:List<&2, String> -> List<&2, String>
def lines source · line 416 · raw
@s:String -> List<&2, String>
Lines with their "\n". Only the last line can lack one, and joining the lines gives s back.
def fnv.go source · line 424 · raw
@s:String -> @+h:U32 -> U32
32-bit FNV-1a, a key for diff_by.
def fnv source · line 431 · raw
@s:String -> U32
def diff_lines source · line 434 · raw
@a:String -> @b:String -> List<&2, Edit<String>>
def diff_chars source · line 437 · raw
@a:String -> @b:String -> List<&2, Edit<Char>>
def far source · line 442 · raw
U32
def ahead.next source · line 445 · raw
@+r:List<&2, U32> -> U32
def ahead.cons source · line 452 · raw
@+change:Bool -> @+r:List<&2, U32> -> List<&2, U32>
def is_change source · line 455 · raw
@-A:Data -> @e:Edit<A> -> Bool
def ahead source · line 463 · raw
@-A:Data -> @es:List<&2, Edit<A>> -> List<&2, U32>
For each edit, how many edits ahead the next change is: 0 for a change.
def rows source · line 475 · raw
@es:List<&2, Edit<String>> -> @ds:List<&2, U32> -> @+ctx:U32 -> @+back:U32 -> List<&2, Row>
def range.pick source · line 491 · raw
@empty:Bool -> @+start:U32 -> @+len:U32 -> String
GNU form: an empty range names the line before it, and a one-line range drops ",1".
def range source · line 499 · raw
@+start:U32 -> @+len:U32 -> String
def hunk.show source · line 502 · raw
@h:Hunk -> String
def close source · line 508 · raw
@cur:Maybe<&2, Hunk> -> @out:List<&2, String> -> List<&2, String>
def open source · line 515 · raw
@cur:Maybe<&2, Hunk> -> @+o:U32 -> @+n:U32 -> Hunk
def eol source · line 523 · raw
@+text:String -> String
Text whose line lacks "\n" is the last line of its file, as diff -u marks it.
def hunk.add source · line 526 · raw
@h:Hunk -> @+text:String -> @+dold:U32 -> @+dnew:U32 -> Hunk
def emit source · line 532 · raw
@rs:List<&2, Row> -> @+o:U32 -> @+n:U32 -> @cur:Maybe<&2, Hunk> -> @out:List<&2, String> -> List<&2, String>
o and n count the old and new lines before the row.
def unified.fin source · line 541 · raw
@hs:List<&2, String> -> @old_name:String -> @new_name:String -> String
def unified source · line 550 · raw
@old_name:String -> @new_name:String -> @+es:List<&2, Edit<String>> -> @+ctx:U32 -> String
Unified diff text with ctx lines of context around each change; "" when nothing changed. Each line must end with "\n" except the last line of a file, as lines() gives them.
def lev.last source · line 563 · raw
@xs:List<&2, U32> -> @+d:U32 -> U32
def lev.init source · line 570 · raw
@n:Nat -> @+i:U32 -> List<&2, U32>
def distance source · line 590 · raw
@a:String -> @b:String -> U32
Levenshtein distance by code point.
def words.flush source · line 595 · raw
@cur:String -> @out:List<&2, String> -> List<&2, String>
def words.step source · line 603 · raw
@sp:Bool -> @+c:Char -> @st:Pair(String, List<&2, String>) -> Pair(String, List<&2, String>)
cur holds the word being read, reversed.
def words.go source · line 612 · raw
@s:String -> @st:Pair(String, List<&2, String>) -> List<&2, String>
def words source · line 621 · raw
@s:String -> List<&2, String>
Runs of non-space chars.
def fits source · line 624 · raw
@+line:String -> @+width:U32 -> Bool
def single.of source · line 627 · raw
@gs:List<&2, String> -> Bool
def single source · line 635 · raw
@+s:String -> Bool
One grapheme cluster: the only kind of line that may be wider than the width.
def ok.pick source · line 638 · raw
@f:Bool -> @+s:String -> Bool
def ok source · line 646 · raw
@+s:String -> @+width:U32 -> Bool
What wrap promises for each line: it fits, or it is one grapheme cluster.
def step0.pick source · line 653 · raw
@f:Bool -> @out:List<&2, String> -> @s:String -> @+c:Char -> Wr
def step0 source · line 660 · raw
@st:Wr -> @+c:Char -> @+width:U32 -> Wr
def run0 source · line 668 · raw
@s:String -> @+width:U32 -> @st:Wr -> Wr
Code points, for a piece that neither fits nor segments as one cluster. One code point is one cluster.
def start1 source · line 675 · raw
@ok:Bool -> @out:List<&2, String> -> @+g:String -> @+width:U32 -> Wr
def step1.pick source · line 682 · raw
@f:Bool -> @out:List<&2, String> -> @s:String -> @+g:String -> @+width:U32 -> Wr
def step1 source · line 689 · raw
@st:Wr -> @+g:String -> @+width:U32 -> Wr
def run1 source · line 697 · raw
@gs:List<&2, String> -> @+width:U32 -> @st:Wr -> Wr
Grapheme clusters, for a word wider than the line.
def start2 source · line 704 · raw
@ok:Bool -> @out:List<&2, String> -> @+w:String -> @+width:U32 -> Wr
def step2.pick source · line 711 · raw
@f:Bool -> @out:List<&2, String> -> @s:String -> @+w:String -> @+width:U32 -> Wr
def step2 source · line 718 · raw
@st:Wr -> @+w:String -> @+width:U32 -> Wr
def run2 source · line 725 · raw
@ws:List<&2, String> -> @+width:U32 -> @st:Wr -> Wr
def wrap.lines source · line 732 · raw
@st:Wr -> List<&2, String>
def wrap.slow source · line 740 · raw
@text:String -> @+width:U32 -> List<&2, String>
Wraps by measuring each candidate line whole. wrap falls back to it.
def all_ok source · line 743 · raw
@ls:List<&2, String> -> @+width:U32 -> Bool
def printable source · line 750 · raw
@+c:U32 -> Bool
def ascii source · line 754 · raw
@s:String -> Bool
Only printable ASCII, so each char is one cluster one column wide.
def last.go source · line 761 · raw
@s:String -> @+c:U32 -> U32
def last source · line 769 · raw
@s:String -> U32
The last code point of s, or 0.
def two source · line 772 · raw
@gs:List<&2, String> -> Bool
def apart source · line 780 · raw
@+c:U32 -> Bool
Whether a cluster boundary falls between code point c and a space. Only a Prepend c joins one.
def fw.end source · line 784 · raw
@aw:Bool -> @w:String -> U32
The end of a line after word w. Any printable ASCII char stands for the last char of a printable ASCII word.
def fw.line source · line 795 · raw
@cur:List<&2, String> -> String
def fw.close source · line 798 · raw
@out:List<&2, String> -> @cur:List<&2, String> -> List<&2, String>
def fw.from source · line 805 · raw
@st:Wr -> Fw
def fw.begin source · line 812 · raw
@fits:Bool -> @out:List<&2, String> -> @+w:String -> @+ww:U32 -> @+width:U32 -> @+aw:Bool -> Fw
def fw.start source · line 819 · raw
@asc:Bool -> @out:List<&2, String> -> @+w:String -> @+width:U32 -> Fw
def fw.add source · line 828 · raw
@fits:Bool -> @out:List<&2, String> -> @+cur:List<&2, String> -> @+nw:U32 -> @+w:String -> @+width:U32 -> @+aw:Bool -> Fw
def fw.join source · line 836 · raw
@sure:Bool -> @+gs:List<&2, String> -> @out:List<&2, String> -> @+cur:List<&2, String> -> @+cw:U32 -> @+w:String -> @+width:U32 -> @+aw:Bool -> Fw
A boundary between the line and the space keeps the line's clusters apart from those of the space and the word, so the widths add.
def fw.next source · line 846 · raw
@asc:Bool -> @out:List<&2, String> -> @+cur:List<&2, String> -> @+cw:U32 -> @+end:U32 -> @+w:String -> @+width:U32 -> @+aw:Bool -> Fw
Printable ASCII on both sides of the space needs no segmentation: each char is one cluster one column wide.
def fw.step.go source · line 854 · raw
@st:Fw -> @+aw:Bool -> @+w:String -> @+width:U32 -> Fw
def fw.step source · line 861 · raw
@st:Fw -> @+w:String -> @+width:U32 -> Fw
def fw.run source · line 864 · raw
@ws:List<&2, String> -> @+width:U32 -> @st:Fw -> Fw
def fw.lines source · line 871 · raw
@st:Fw -> List<&2, String>
def wrap.fast source · line 877 · raw
@text:String -> @+width:U32 -> List<&2, String>
The same lines as wrap.slow, adding widths when no cluster spans the joining space.
def wrap.pick source · line 880 · raw
@good:Bool -> @ls:List<&2, String> -> @text:String -> @+width:U32 -> List<&2, String>
def wrap source · line 890 · raw
@+text:String -> @+width:U32 -> List<&2, String>
Greedy word wrap to width display columns. Whitespace runs separate words; lines join words with one space. A word wider than width breaks between grapheme clusters; a cluster wider than width stays whole on its own line. The fast path's lines are checked with ok; if one fails, every line is measured whole instead.
Templates
template same.b source · line 108 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @x:A -> @a:Array<A> -> @r:Pair(Array<A>, A) -> Pair(Array<A>, Pair(Array<A>, Bool))
template same.a source · line 112 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @r:Pair(Array<A>, A) -> @b:Array<A> -> @+j:U32 -> Pair(Array<A>, Pair(Array<A>, Bool))
template probe.in source · line 116 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @inr:Bool -> @a:Array<A> -> @b:Array<A> -> @+rev:Bool -> @+g:Geo -> @+x:U32 -> @+y:U32 -> Pair(Array<A>, Pair(Array<A>, Bool))
template probe source · line 126 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @a:Array<A> -> @b:Array<A> -> @+rev:Bool -> @+g:Geo -> @+x:U32 -> @+y:U32 -> Pair(Array<A>, Pair(Array<A>, Bool))
Whether item x of the segment of a matches item y of the segment of b. rev counts from the segment end.
template snake source · line 129 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @fuel:Nat -> @r:Pair(Array<A>, Pair(Array<A>, Bool)) -> @+rev:Bool -> @+g:Geo -> @+x:U32 -> @+y:U32 -> Pair(Array<A>, Pair(Array<A>, U32))
template slide source · line 143 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @a:Array<A> -> @b:Array<A> -> @+rev:Bool -> @+g:Geo -> @+x:U32 -> @+y:U32 -> Pair(Array<A>, Pair(Array<A>, U32))
The x where the run of matches from (x, y) ends.
template ctx.mk source · line 147 · raw
@-A:Data -> @rev:Bool -> @a:Array<A> -> @b:Array<A> -> @v:Array<U32> -> @w:Array<U32> -> Ctx<A>
v is the frontier that moves, w the other one.
template at.hit source · line 154 · raw
@-A:Data -> @r:Pair(Array<U32>, U32) -> @a:Array<A> -> @b:Array<A> -> @v:Array<U32> -> @+rev:Bool -> @+g:Geo -> @+k:U32 -> @+x:U32 -> @+x0:U32 -> Pair(Ctx<A>, Maybe<&2, Pt>)
template at.chk source · line 159 · raw
@-A:Data -> @on:Bool -> @a:Array<A> -> @b:Array<A> -> @v:Array<U32> -> @w:Array<U32> -> @+rev:Bool -> @+g:Geo -> @+k:U32 -> @+x:U32 -> @+x0:U32 -> Pair(Ctx<A>, Maybe<&2, Pt>)
template at.snk source · line 167 · raw
@-A:Data -> @r:Pair(Array<A>, Pair(Array<A>, U32)) -> @v:Array<U32> -> @w:Array<U32> -> @+rev:Bool -> @+g:Geo -> @+d:U32 -> @+k:U32 -> @+x0:U32 -> Pair(Ctx<A>, Maybe<&2, Pt>)
Myers' overlap test: forward d-paths meet reverse (d-1)-paths when n - m is odd, reverse d-paths when even.
template at.hi source · line 178 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @r:Pair(Array<U32>, U32) -> @+lo:U32 -> @a:Array<A> -> @b:Array<A> -> @w:Array<U32> -> @+rev:Bool -> @+g:Geo -> @+d:U32 -> @+k:U32 -> Pair(Ctx<A>, Maybe<&2, Pt>)
Myers' rule for diagonal k: go down from k+1 when V[k-1] < V[k+1], else right from k-1.
template at.lo source · line 184 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @r:Pair(Array<U32>, U32) -> @a:Array<A> -> @b:Array<A> -> @w:Array<U32> -> @+rev:Bool -> @+g:Geo -> @+d:U32 -> @+k:U32 -> Pair(Ctx<A>, Maybe<&2, Pt>)
template at source · line 189 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @rev:Bool -> @c:Ctx<A> -> @+g:Geo -> @+d:U32 -> @+k:U32 -> Pair(Ctx<A>, Maybe<&2, Pt>)
One diagonal of one sweep.
template sweep source · line 197 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @fuel:Nat -> @r:Pair(Ctx<A>, Maybe<&2, Pt>) -> @+rev:Bool -> @+g:Geo -> @+d:U32 -> @+k:U32 -> Pair(Ctx<A>, Maybe<&2, Pt>)
Diagonals k, k + 2, ... until fuel runs out or a sweep meets the other frontier.
template round.back source · line 210 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @r:Pair(Ctx<A>, Maybe<&2, Pt>) -> @+g:Geo -> @+d:U32 -> Pair(Ctx<A>, Maybe<&2, Pt>)
template round source · line 218 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @c:Ctx<A> -> @+g:Geo -> @+d:U32 -> Pair(Ctx<A>, Maybe<&2, Pt>)
template middle.go source · line 221 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @fuel:Nat -> @r:Pair(Ctx<A>, Maybe<&2, Pt>) -> @+g:Geo -> @+d:U32 -> Pair(Ctx<A>, Maybe<&2, Pt>)
template middle source · line 235 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @c:Ctx<A> -> @+g:Geo -> Pair(Ctx<A>, Maybe<&2, Pt>)
Myers' middle snake: grow d-paths from both ends of the segment until they meet. The meeting point is on a shortest path.
template plan.split source · line 250 · raw
@-A:Data -> @r:Pair(Ctx<A>, Maybe<&2, Pt>) -> @+os:U32 -> @+oe:U32 -> @+ns:U32 -> @+ne:U32 -> Pair(Ctx<A>, List<&2, Job>)
template plan.mid source · line 258 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @ea:Bool -> @eb:Bool -> @c:Ctx<A> -> @+os:U32 -> @+oe:U32 -> @+ns:U32 -> @+ne:U32 -> @+off:U32 -> Pair(Ctx<A>, List<&2, Job>)
template plan.wrap source · line 267 · raw
@-A:Data -> @r:Pair(Ctx<A>, List<&2, Job>) -> @+p:U32 -> @+s:U32 -> Pair(Ctx<A>, List<&2, Job>)
template plan.suf source · line 272 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @r:Pair(Array<A>, Pair(Array<A>, U32)) -> @vf:Array<U32> -> @vb:Array<U32> -> @+p:U32 -> @+os:U32 -> @+oe:U32 -> @+ns:U32 -> @+ne:U32 -> @+off:U32 -> Pair(Ctx<A>, List<&2, Job>)
template plan.pre source · line 281 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @r:Pair(Array<A>, Pair(Array<A>, U32)) -> @vf:Array<U32> -> @vb:Array<U32> -> @+os:U32 -> @+oe:U32 -> @+ns:U32 -> @+ne:U32 -> @+off:U32 -> Pair(Ctx<A>, List<&2, Job>)
template plan source · line 288 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @c:Ctx<A> -> @+os:U32 -> @+oe:U32 -> @+ns:U32 -> @+ne:U32 -> @+off:U32 -> Pair(Ctx<A>, List<&2, Job>)
Jobs for one segment, last first: the common suffix, the middle, then the common prefix.
template plan.then source · line 293 · raw
@-A:Data -> @r:Pair(Ctx<A>, List<&2, Job>) -> @t:List<&2, Job> -> Pair(Ctx<A>, List<&2, Job>)
template solve source · line 298 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @fuel:Nat -> @r:Pair(Ctx<A>, List<&2, Job>) -> @+off:U32 -> @acc:List<&2, Move> -> List<&2, Move>
Runs jobs from the end of the script back to its start, so each emit prepends.
template fill source · line 328 · raw
@-A:Data -> @xs:List<&2, A> -> @arr:Array<A> -> @+i:U32 -> Array<A>
template array source · line 336 · raw
@-A:Data -> @+n:U32 -> @+v:A -> Array<A>
An array of n slots or more.
template moves.go source · line 340 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @+x:A -> @+y:A -> @+a:List<&2, A> -> @+b:List<&2, A> -> List<&2, Move>
Each split leaves two smaller segments, and each segment plans at most 4 jobs.
template moves source · line 348 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @+a:List<&2, A> -> @+b:List<&2, A> -> List<&2, Move>
template diff source · line 360 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @+a:List<&2, A> -> @+b:List<&2, A> -> List<&2, Edit<A>>
A shortest edit script from a to b. eq decides which items match.
template keys source · line 363 · raw
@-A:Data -> @-key:(@_:A -> U32) -> @xs:List<&2, A> -> List<&2, U32>
template paired source · line 371 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @ms:List<&2, Move> -> @a:List<&2, A> -> @b:List<&2, A> -> Bool
Whether every pair that walk would match is equal by eq.
template moves_by.pick source · line 384 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @ok:Bool -> @ms:List<&2, Move> -> @+a:List<&2, A> -> @+b:List<&2, A> -> List<&2, Move>
template moves_by source · line 392 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @-key:(@_:A -> U32) -> @+a:List<&2, A> -> @+b:List<&2, A> -> List<&2, Move>
Diffs the keys, then checks each matched pair with eq. If two unequal items share a key and get matched, it diffs the items instead.
template diff_by source · line 398 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @-key:(@_:A -> U32) -> @+a:List<&2, A> -> @+b:List<&2, A> -> List<&2, Edit<A>>
diff, but Myers compares U32 keys, which is much faster than comparing items such as strings. Equal items must have equal keys. The script is the same length as diff's.
template lev.row source · line 555 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @b:List<&2, A> -> @up:List<&2, U32> -> @+x:A -> @+diag:U32 -> @+left:U32 -> List<&2, U32>
template lev.go source · line 577 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @a:List<&2, A> -> @+b:List<&2, A> -> @prev:List<&2, U32> -> @+i:U32 -> U32
template edit_distance source · line 586 · raw
@-A:Data -> @-eq:(@_:A -> @_:A -> Bool) -> @a:List<&2, A> -> @+b:List<&2, A> -> U32
Fewest inserts, deletes, and substitutions that turn a into b.