mod

From the SETL Wiki

Jump to: navigation, search
mod
Category numeric
Syntax infix
Compatibility
CIMS SETL yes
SETL-S yes
SETL2 yes
GNU SETL yes

Contents

Purpose

Integer modulus or symmetric set difference

Synopsis

 x mod y

Description

Either

  1. x and y must both be integers, and the result is the positive remainder when x is divided by y, or
  2. x and y must both be sets, and the result is a set containing every element in either x or y (but not in both).

The first case can also be defined as the smallest non-negative integer z such that (x - z) is an exact multiple of y.
In the second case it is equivalent to (x + y) - (x * y).

Examples

  1. {1, 2, 3, 4, 5} mod {4, 5, 6}
    

    Result: {1, 2, 3, 6}

  2. 14 mod 10
    

    Result: 4

  3. -14 mod 10
    

    Result: 6


Notes

There is a difference between implementations when y is negative:

In all cases the result is non-negative.

Personal tools