Skip to content
/ go.diff Public

A Go implementation of "An O(NP) Sequence Comparison Algorithm"

License

Notifications You must be signed in to change notification settings

hattya/go.diff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go.diff

A Go implementation of "An O(NP) Sequence Comparison Algorithm".

pkg.go.dev GitHub Actions Appveyor Codecov

Installation

$ go get -u github.com/hattya/go.diff

Usage

package main

import (
	"fmt"

	"github.com/hattya/go.diff"
)

func main() {
	a := []rune("acbdeacbed")
	b := []rune("acebdabbabed")
	cl := diff.Runes(a, b)
	i := 0
	for _, c := range cl {
		for ; i < c.A; i++ {
			fmt.Printf("  %c\n", a[i])
		}
		for j := c.A; j < c.A+c.Del; j++ {
			fmt.Printf("- %c\n", a[j])
		}
		for j := c.B; j < c.B+c.Ins; j++ {
			fmt.Printf("+ %c\n", b[j])
		}
		i += c.Del
	}
	for ; i < len(a); i++ {
		fmt.Printf("  %c\n", a[i])
	}
}

License

go.diff is distributed under the terms of the MIT License.

References

S. Wu, U. Manber, G. Myers, and W. Miller, "An O(NP) Sequence Comparison Algorithm" August 1989

About

A Go implementation of "An O(NP) Sequence Comparison Algorithm"

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages