Operators

(in ./Carbon/Operators.lua)

Provides functional forms of operators. Useful for having a common base.

DEPRECATED in 1.1: Use fat-arrow lambdas or your own functions instead.


Methods

class public Operators.Sign(number n)

Returns number

  • required n: The number to check the sign of.

Returns the sign of a number as a signed number.

Positive numbers result in 1

Negative numbers result in -1

Zero results in 0


class public Operators.Add(any a, any b)

Returns

  • required a: The first value to add.
  • required b: The second value to add.

Adds two objects together. a + b


class public Operators.AddN(...)

Returns

  • required ...: Values to add.

Adds any number of objects together. a + b + c + d + ...


class public Operators.Subtract(any a, any b)

Returns

  • required a: The value to subtract from.
  • required b: The value to subtract.

Subtracts an object from another. a - b


class public Operators.SubtractN(...)

Returns

  • required ...: The values to use in a subtraction expression.

Subtracts a series of objects from eachother. a - b - c - d - ...


class public Operators.Multiply(any a, any b)

Returns

  • required a: The first value to multiply.
  • required b: The second value to multiply.

Multiplies two objects together. a * b


class public Operators.MultiplyN(...)

Returns

  • required ...: The values to multiply together.

Multiples a series of objects together. a * b * c * d * ...


class public Operators.Divide(any a, any b)

Returns

  • required a: The dividend.
  • required b: The divisor.

Performs division between two objects. a / b


class public Operators.DivideN(...)

Returns

  • required ...: A list of objects to use in a chain division.

Divides a series of objects from the left. a / b / c / d / ...


class public Operators.Power(any a, any b)

Returns

  • required a: The base.
  • required b: The exponent.

Performs exponentiation with two numbers. a ^ b


class public Operators.PowerN(...)

Returns

  • required ...: The values to use in a chained exponentiation expression.

Raises values to powers given by a list in a left-associative way. ((((a ^ b) ^ c) ^ d) ^ ...)


class public Operators.Concat(any a, any b)

Returns

  • required a: The first value to concat.
  • required b: The second value to concat.

Performs concatenation with two objects. a .. b


class public Operators.ConcatN(...)

Returns

  • required ...: The values to concat.

Performs concatenation with a list of objects. a .. b .. c .. d .. ...


class public Operators.Equal(any a, any b)

Returns bool

  • required a: The first value.
  • required b: The second value.

Returns whether two values are equal. Uses the __eq metamethod.


class public Operators.GreaterThan(any a, any b)

Returns bool

  • required a: The first value.
  • required b: The second value.

Returns whether a is greater than b. Uses the le metamethod if available, otherwise uses lt and __eq.


class public Operators.GreaterThanEqualTo(any a, any b)

Returns bool

  • required a: The first value.
  • required b: The second value.

Returns whether a is greater than or equal to b. Uses the lt and eq metamethods.


class public Operators.LessThan(any a, any b)

Returns bool

  • required a: The first value.
  • required b: The second value.

Returns whether a is less than b. Uses the __lt metamethod.


class public Operators.LessThanEqualTo(any a, any b)

Returns bool

  • required a: The first value.
  • required b: The second value.

Returns whether a is less than or equal to b. Uses the le metamethod if available, otherwise uses lt and __eq.


class public Operators.NotEqual(any a, any b)

Returns bool

  • required a: The first value.
  • required b: the second value.

Returns whether two values are not equal. Uses the __eq metamethod.


Properties

[none]