This is my pseudo code, obviously this is not idiomatic scala as I use a lot of mutable variables and loops.
My goal is to transform this into idiomatic scala in a functional way.
The objective of the algorithm is that given a list of strings, do a N^2 comparison on itself to find matches using edit distance. Because edit distance checks are example, I want to avoid doing edit distance checks on string pairs that have been checked.
def pairwisecomp(block: Iterable[String]): List[(String, String)] = {
var matches = new ListBuffer[(String, String)]
// pseudo code; not intended to be valid scala
for (var i = 0; i < block.size; i++) {
val str1 = block[i]
// iterate from i because no need to go backwards to compare
for (var j = i+1; j < block.size; j++) {
val str2 = block[j]
// check edit distance
// if less than 2, append into the matches
if (editDistance(str1, str2) < 2) {
matches.append((str1, str2))
}
}
}
return matches.toList
}