src/lcs.js
function(xs, ys, matrix){
  var lcs = [];
  for(var i = xs.size, j = ys.size; i !== 0 && j !== 0;){
    if (matrix[i][j] === matrix[i-1][j]){ i--; }
    else if (matrix[i][j] === matrix[i][j-1]){ j--; }
    else{
      if(Immutable.is(xs.get(i-1), ys.get(j-1))){
        lcs.push(xs.get(i-1));
        i--;
        j--;
      }
    }
  }
  return lcs.reverse();
}
function(xs, ys, matrix){
  var lcs = [];
  for(var i = xs.size, j = ys.size; i !== 0 && j !== 0;){
    if (matrix[i][j] === matrix[i-1][j]){ i--; }
    else if (matrix[i][j] === matrix[i][j-1]){ j--; }
    else{
      if(Immutable.is(xs.get(i-1), ys.get(j-1))){
        lcs.push(xs.get(i-1));
        i--;
        j--;
      }
    }
  }
  return lcs.reverse();
}
function ( xs , ys , matrix ) { var lcs = [ ] ; for ( var i = xs . size , j = ys . size ; i !== 0 && j !== 0 ; ) { if ( matrix [ i ] [ j ] === matrix [ i - 1 ] [ j ] ) { i -- ; } else if ( matrix [ i ] [ j ] === matrix [ i ] [ j - 1 ] ) { j -- ; } else { if ( Immutable . is ( xs . get ( i - 1 ) , ys . get ( j - 1 ) ) ) { lcs . push ( xs . get ( i - 1 ) ) ; i -- ; j -- ; } } } return lcs . reverse ( ) ; }
Extracts a LCS from matrix M
@param xs Indexed Sequence 1
@param ys Indexed Sequence 2
@param matrix LCS Matrix
@returns {Array.<T>} Longest Common Subsequence
Extracts a LCS from matrix M