Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,15 @@
func lev(s, t) is cached {
 
s || return t.len
t || return s.len
 
var s1 = s.ft(1)
var t1 = t.ft(1)
 
s[0] == t[0] ? __FUNC__(s1, t1)
 : 1+Math.min(
__FUNC__(s1, t1),
__FUNC__(s, t1),
__FUNC__(s1, t )
)
}

View file

@ -0,0 +1,11 @@
func lev(s, t) {
var d = [@(0 .. t.len), s.len.of {[_]}...]
for i,j in (^s ~X ^t) {
d[i+1][j+1] = (
s[i] == t[j]
? d[i][j]
: 1+Math.min(d[i][j+1], d[i+1][j], d[i][j])
)
}
d[-1][-1]
}

View file

@ -0,0 +1,2 @@
say lev(%c'kitten', %c'sitting'); # prints: 3
say lev(%c'rosettacode', %c'raisethysword'); # prints: 8