core : number

All numbers in Brat are number objects. Currently, they use Lua's built-in numbers, with the same limitations.
==   >=   <=   >   <   +   -   *   /   %   ^   new   number?   of   sin   tan   times   to   to_char   to_hex   to_i   to_rad   to_s  

(boolean) ==

num1 == num2

Checks for equality. Note that 1.0 == 1.

(boolean) >=

num1 >= num2

Greater than or equal to.

(boolean) <=

num1 <= num2

Less than or equal to.

(boolean) >

num1 > num2

Greater than.

(boolean) <

num1 < num2

Less than.

(number) %

lhs % rhs

Performs the modulo operation.

(number) *

lhs * rhs

Performs multiplication.

(number) +

lhs + rhs

Performs addition.

(number) -

lhs - rhs

Performs subtraction.

(number) /

lhs / rhs

Performs division.

(number) ^

lhs ^ rhs

Performs exponentiation.

(number) cos


Returns the cosine.

(number) new num

Create a new number object. No real reason to use this directly.

(true) number?


Returns true.

(array) of

number.of item

Generates an array of the given item. If item is a function, uses the result of calling it the specified number of times.

 3.of "ha" # Returns ["ha", "ha", "ha"]

(number) sin


Returns the sine.

(number) tan


Returns the tangent.

(number) times

number.times block

Performs the block the specified number of times. Passes in the current number to the function.

(object) to limit limit, block

With no function argument, returns an array containing the numbers from the target to the limit (inclusive). If given a function argument, loops from target to limit, passing in the current number as an argument. 1 { n | p n }  # Prints 10 to 1 in decreasing order.

(string) to_char


Converts number to ASCII representation.

(string) to_hex


Converts number to hexadecimal.

(number) to_i


Truncates number.

(number) to_rad


Converts to radians.

(string) to_s


Returns a string version of the number.

Fork me on GitHub