/// Checks whether `$coords` are valid coordinates
/// @access private
/// @group helpers
/// @param $coords - coordinates
/// @param {Matrix} $matrix (null) - matrix
/// @return {Bool}
/// @require {function} rows
/// @require {function} columns
@function _valid-coords($coords, $matrix: null) {
  @if length($coords) == 1 {
    $coords: ($coords, $coords);
  }

  $x: nth($coords, 1);
  $y: nth($coords, 2);

  @if length($coords) != 2 {
    @warn "Wrong number of coordinates.";
    @return false;
  }

  @if type-of($x) != number or type-of($y) != number {
    @warn "Invalid coordinates.";
    @return false;
  }

  @if $matrix {
    @if abs($x) > rows($matrix) or abs($y) > columns($matrix) {
      @warn "Out of bound coordinates.";
      @return false;
    }
  }

  @return true;
}
