diff --git a/src/lib.zig b/src/lib.zig index 20f87c9ae51bf9aa403baa50d49275a1eb75a436..285892e5d7ee09fe9e732d4e953e90f6c0c29202 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const range = @import("range").range; // // the naïve recursive implementation // 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 const array = try alloc.alloc(usize, ll); defer alloc.free(array); - for (range(ll), 0..) |_, i| { + for (0..ll) |i| { charCodeCache[i] = left[start + i]; array[i] = i + 1; } - for (range(rl), 0..) |_, j| { + for (0..rl) |j| { const bCharCode = right[start + j]; var temp = j; result = j + 1; - for (range(ll), 0..) |_, i| { + for (0..ll) |i| { const temp2 = if (bCharCode == charCodeCache[i]) temp else temp + 1; temp = array[i]; array[i] = if (temp > result) (if (temp2 > result) result + 1 else temp2) else (if (temp2 > temp) temp + 1 else temp2); diff --git a/zig.mod b/zig.mod index dfcb46cdfcce6d9e9133f9c5424cf89514976d70..a223018c23bbce80aa31465aa4ead7bde80be8bf 100644 --- a/zig.mod +++ b/zig.mod @@ -3,5 +3,3 @@ name: leven main: src/lib.zig license: MIT description: Measure the difference between two slices using the Levenshtein distance algorithm -dependencies: - - src: git https://github.com/nektro/zig-range