List utilities Compare two ordered lists of objects of any type

List utilities

A JVM library to compare two lists, l1 and l1, of objects of any kind.

Overview

Use the ListDiff class to find:

  • the longest common subsequence (LCS) of the two lists (an ordered intersection of l1 and l2)
  • the shortest common supersequence (SCS) of the two lists (an ordered union of l1 and l2)
  • the ordered list of items contained only in l1
  • the ordered list of items contained only in l2
  • differences between l1 and l2

Documentation and maven identifiers

CL scripts for printing LCS and SCS of two strings

Groovy scripts with a grapes dependency on listutils to apply LCS and SCS to sequences of characters in two strings:

Examples:

 groovy lcs.groovy 'Dr Rock-and-Roll Star' 'Doctor Rock Star'

prints

 Dr Rock Star

while

 groovy scs.groovy 'Dr Rock-and-Roll Star' 'Doctor Rock Star'

prints

 Doctor Rock-and-Roll Star