Function in prelude::math auto-imported

diff

fn diff<D, M>(Matrix<D> a, Matrix<D> b) -> Matrix<M>
Source: compiler/src/builtin_docs/prelude/math.hy

Returns a byte mask that is 1 where a has a non-zero cell and b has 0.

Same shape rules as intersect. The result is a Matrix of byte cells.

Parameters#

NameType
aMatrix<D>
bMatrix<D>

Returns#

Matrix<M>

Examples#

use tests::assert;
let a = matrix([[1, 2], [3, 0]]);
let b = matrix([[1, 0], [0, 0]]);
let d = diff(a, b);
assert!(d[0][0] == 0 as byte);
assert!(d[0][1] == 1 as byte);
assert!(d[1][0] == 1 as byte);
assert!(d[1][1] == 0 as byte);

See also#

  • byte
  • intersect
  • Matrix
  • sin: Returns the sine of x (in radians).
  • cos: Returns the cosine of x (in radians).
  • tan: Returns the tangent of x (in radians).
  • sqrt: Returns the square root of x.
  • floor: Returns the largest whole number less than or equal to x, as a float.
↑ ↓ navigate ↵ open