# scala3_diff **Repository Path**: SuperWindcloud/scala3_diff ## Basic Information - **Project Name**: scala3_diff - **Description**: scala3 的diff 差异算法实现 - **Primary Language**: Unknown - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-01-10 - **Last Updated**: 2025-01-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # scala3_diff #### 介绍 ## scala3 的diff 差异算法实现 ### 一个小型、零依赖的Scala库,提供 diff 算法的高效实现 > 迈尔斯的算法是许多流行工具(如git diff )的默认比较逻辑,因为它表现良好(时间和内存方面),并且往往会产生人类认为“好”的比较结果。 ## 添加依赖到sbt `libraryDependencies ++= Seq( "io.bullet" %% "spliff" % "0.8.0" )` ## 用法示例 ```scala val diff = Diff( "the base sequence", "the target sequence" ) // 从 `base` 到 `target` 所需的所有删除操作 val deletes: Seq[Diff.Op.Delete] = diff.deletes println(deletes.toSeq) // the ae sequence // 从 `base` 到 `target` 所需的所有插入操作 val inserts: Seq[Diff.Op.Insert] = diff.inserts println(inserts) val delIns: Seq[Diff.Op.DelIns] = diff.delInsOps println(delIns) val delInsSorted: Seq[Diff.Op.DelIns] = diff.delInsOpsSorted // same but sorted by index println(delInsSorted) ```