/// Add a new `$row` to `$matrix`
/// @group setters
/// @param {Matrix} $matrix - matrix
/// @param {List} $row (()) - row to add
/// @param {Number | Null} $index (null) - index to add row at
/// @return {Matrix}
/// @require {function} swap-rows
/// @require {function} columns
@function add-row($matrix, $row: (), $index: null) {
  $desired-length: columns($matrix);

  @if $row == () {
    @for $i from 1 through $desired-length {
      $row: append($row, 0);
    }
  }

  @if length($row) != $desired-length {
    @warn "Wrong length for new row; should be #{$desired-length}.";
    @return false;
  }

  $matrix: append($matrix, $row);

  @if $index != null {
    $matrix: swap-rows($matrix, -1, $index);
  }

  @return $matrix;
}
