code: function createDistanceArray(input, distance) {
    var length = input.length
    var matrix = new Array(length)
    for (var i = 0; i < length; i++) {
      matrix[i] = new Array(i)
      for (var j = 0; j < i; j++)
        matrix[i][j] = distance(input[i], input[j])
    }
  
    return matrix
  }
docs: Create the upper triangle of the symmetric, distance matrix.
  Only i > j is valid for matrix[i][j].