cj1128 / myers-diff Goto Github PK
View Code? Open in Web Editor NEW😍 Golang implementation for myers diff algorithm
😍 Golang implementation for myers diff algorithm
thanks your implementation helped me to understand the algorithm。
Line 200 in 9678f9a
not all k in [-d, d] will save in trace. if k not in trace x := v[k]
x will be zero as default.
may be this is the better
func printTrace(trace []map[int]int) {
for d := 0; d < len(trace); d++ {
fmt.Printf("d = %d:\n", d)
v := trace[d]
for k, x := range v {
y := x - k
fmt.Printf(" k = %2d: (%d, %d)\n", k, x, y)
}
}
}
https://github.com/fate-lovely/myers-diff/blob/4613bf7fbf0ba327d5e9069d364e78b721cca17e/main.go#L157
我使用
A B C D E
和
A B D E
测试的时候,结果是
-A B C
,定位到错误应该是在回溯的时候,这里d==0的时候也应该考虑进去,如果两个文本前面内容相同,需要在d==0的时候执行添加MOV的操作。在https://github.com/pkg/diff/blob/7e42a82532c282d39d727ace02bfdef801c6db2c/myers.go#L71 这个实现里面就有考虑d==0的情况
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.