Modulo

Modulo( value_1, value_2, ... )
Modulo( value_1, value_2, ... )
Modulo( value_1, value_2, ... )
Modulo( value_1, value_2, ... )
modulo( value_1, value_2, ... )
Modulo( value_1, value_2, ... )

Description

The Modulo function computes the remainder after division on a list of numbers. Providing a single operand returns the operand.

Attempting to call Modulo with an empty list results in the error "Non-empty array expected."

Attempting to compute the remainder of a division by zero results in the error "Illegal division by zero."

Parameters

Parameter Type Definition and Requirements

value

List of Numbers

A single value or a list of values.

Returns

A Number which is the modulo from the value list.

Examples

try
{
    Value result = await client.Query(
        Modulo(10, 5, 2)
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
LongV(0)
result, err := client.Query(
	f.Modulo(10, 5, 2))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
0
System.out.println(
    client.query(
        Modulo(Value(10), Value(5), Value(2))
    ).get());
0
client.query(
  q.Modulo(10, 5, 2)
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
0
result = client.query(
  q.modulo(10, 5, 2)
)
print(result)
0
Modulo(10, 5, 2)
0
Query metrics:
  •    bytesIn:  19

  •   bytesOut:  14

  • computeOps:   1

  •    readOps:   0

  •   writeOps:   0

  •  readBytes:   0

  • writeBytes:   0

  •  queryTime: 4ms

  •    retries:   0

is equivalent to:

try
{
    Value result = await client.Query(
        Modulo(Modulo(10, 5), 2)
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
LongV(0)
result, err := client.Query(
	f.Modulo(f.Modulo(10, 5), 2))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
0
System.out.println(
    client.query(
        Modulo(Modulo(Value(10), Value(5)), Value(2))
    ).get());
0
client.query(
  q.Modulo(q.Modulo(10, 5), 2)
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
0
result = client.query(
  q.modulo(q.modulo(10, 5), 2)
)
print(result)
0
Modulo(Modulo(10, 5), 2)
0
Query metrics:
  •    bytesIn:  32

  •   bytesOut:  14

  • computeOps:   1

  •    readOps:   0

  •   writeOps:   0

  •  readBytes:   0

  • writeBytes:   0

  •  queryTime: 2ms

  •    retries:   0

Was this article helpful? 

We're sorry to hear that.
Tell us how we can improve!
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!