1a: Basic Arithmetic

+add

Add.

Produces the sum of .a and .b.

Accepts

.a is an $atom.

.b is an $atom.

Produces

An $atom.

Source

++  add
  ~/  %add
  |=  [a=@ b=@]
  ^-  @
  ?:  =(0 a)  b
  $(a (dec a), b +(b))

Examples


+dec

Decrement.

Decrements .a by 1.

Accepts

.a is an $atom.

Produces

An $atom.

Source

Examples


+div

Divide.

Computes .a divided by .b without remainder.

Accepts

.a is an $atom.

.b is an $atom.

Produces

An $atom.

Source

Examples


+dvr

Divide with remainder.

Computes .a divided by .b, producing the quotient and the remainder.

Accepts

.a is an $atom.

.b is an $atom.

Produces

A cell of $atoms.

Source

Examples


+gte

Greater-than/equal.

Tests whether .a is greater than or equal to .b.

Accepts

.a is an $atom.

.b is an $atom.

Produces

A $flag.

Source

Examples


+gth

Greater-than.

Tests whether .a is greater than .b.

Accepts

.a is an $atom.

.b is an $atom.

Produces

A $flag.

Source

Examples


+lte

Less-than/equal.

Tests whether .a is less than or equal to .b.

Accepts

.a is an $atom.

.b is an $atom.

Produces

A $flag.

Source

Examples


+lth

Less-than.

Tests whether .a is less than .b.

Accepts

.a is an $atom.

.b is an $atom.

Produces

A $flag.

Source

Examples


+max

Maximum.

Computes the greater of .a and .b.

Accepts

.a is an $atom.

.b is an $atom.

Produces

An $atom.

Source

Examples


+min

Minimum.

Computes the lesser of .a and .b.

Accepts

.a is an $atom.

.b is an $atom.

Produces

An $atom.

Source

Examples


+mod

Modulus.

Computes the remainder of dividing .a by .b.

Accepts

.a is an $atom.

.b is an $atom.

Produces

An $atom.

Source

Examples


+mul

Multiply.

Multiplies .a by .b.

Accepts

.a is an $atom.

.b is an $atom.

Produces

An $atom.

Source

Examples


+sub

Subtract.

Subtracts .b from .a.

Accepts

.a is an $atom.

.b is an $atom.

Produces

An $atom.

Source

Examples

Last updated