Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Latest commit

 

History

History

lite-gestalt

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

lite-gestalt

Computes a diff between two sequences by using Gestalt Pattern Matching.

Maven Central

Install

Insert the following to your build.sbt.

libraryDependencies += "codes.quine.labo" %% "lite-gestalt" % "<latest version>"

Usage

Gestalt.diff(seq1, seq2) computes a diff between seq1 and seq2 by using Gestalt Pattern Matching algorithm. It returns a Patch object, and we can generate a unified diff format text from this patch.

Note that Gestalt.diff accepts any values whose equality and hash function is defined correctly.

import codes.quine.labo.lite.gestalt.Gestalt

val seq1 = Seq(1, 2, 3, 4, 5)
val seq2 = Seq(1, 2, 2, 5, 6)

val patch = Gestalt.diff(seq1, seq2)
patch.toUnified()
// res0: String =
// "@@ -1,5 +1,5
//  1
//  2
// -3
// -4
// +2
//  5
// +6
// "