authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2024-06-05 01:39:04 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2024-06-05 01:39:04 -07:00
loge5481b297b6023d446d835156591ba5ce88c17be
tree351a075a108db6b3e09fc0cf172a88f9a548d6c3
parente548b0bcc7b6f34f636c0b6b905928d31254c54d

remove nektro/zig-range


2 files changed, 3 insertions(+), 6 deletions(-)

src/lib.zig+3-4
...@@ -1,5 +1,4 @@...@@ -1,5 +1,4 @@
1const std = @import("std");1const std = @import("std");
2const range = @import("range").range;
32
4// // the naïve recursive implementation3// // the naïve recursive implementation
5// pub fn leven(comptime T: type, a: []const T, b: []const T) usize {4// pub fn leven(comptime T: type, a: []const T, b: []const T) usize {
...@@ -53,17 +52,17 @@ pub fn leven(comptime T: type, alloc: std.mem.Allocator, a: []const T, b: []cons...@@ -53,17 +52,17 @@ pub fn leven(comptime T: type, alloc: std.mem.Allocator, a: []const T, b: []cons
53 const array = try alloc.alloc(usize, ll);52 const array = try alloc.alloc(usize, ll);
54 defer alloc.free(array);53 defer alloc.free(array);
5554
56 for (range(ll), 0..) |_, i| {55 for (0..ll) |i| {
57 charCodeCache[i] = left[start + i];56 charCodeCache[i] = left[start + i];
58 array[i] = i + 1;57 array[i] = i + 1;
59 }58 }
6059
61 for (range(rl), 0..) |_, j| {60 for (0..rl) |j| {
62 const bCharCode = right[start + j];61 const bCharCode = right[start + j];
63 var temp = j;62 var temp = j;
64 result = j + 1;63 result = j + 1;
6564
66 for (range(ll), 0..) |_, i| {65 for (0..ll) |i| {
67 const temp2 = if (bCharCode == charCodeCache[i]) temp else temp + 1;66 const temp2 = if (bCharCode == charCodeCache[i]) temp else temp + 1;
68 temp = array[i];67 temp = array[i];
69 array[i] = if (temp > result) (if (temp2 > result) result + 1 else temp2) else (if (temp2 > temp) temp + 1 else temp2);68 array[i] = if (temp > result) (if (temp2 > result) result + 1 else temp2) else (if (temp2 > temp) temp + 1 else temp2);
zig.mod-2
...@@ -3,5 +3,3 @@ name: leven...@@ -3,5 +3,3 @@ name: leven
3main: src/lib.zig3main: src/lib.zig
4license: MIT4license: MIT
5description: Measure the difference between two slices using the Levenshtein distance algorithm5description: Measure the difference between two slices using the Levenshtein distance algorithm
6dependencies:
7 - src: git https://github.com/nektro/zig-range