CDuce/Types/Int

From Wikibooks, open books for an open world
< CDuce‎ | Types
Jump to navigation Jump to search

CDuce integers are arbitrarly large, positive or negative. The three literals 9 09 009 correspond to the same integer. It corresponds also to the type "integer of value nine" which is a singleton set containing the integer 9.

#print_type 9;;
-> 9

The expression

type Foo = 1 | 2 | 3 | 4

define the type Foo which corresponds to the set containing the first four positive integer. An other way to construct a set of consecutive integers:

type Foo = 1--4
#print_type -1 | -2 | -3;;
-> -3---1

The sets of strictly positive and strictly negative integers, and constructions from them

type Positive = 1--*
type Negative = *---1
type NonNul = Positive | Negative
#print_type NonNul | 0
-> Int