Feel.Analysis.IntegerSet (feel v0.1.0)

Copy Markdown View Source

Sets of whole numbers, as sets of numbers (D-109).

The properties of a date and of a duration that are whole numbers (a year, a month, the hours of a duration) are worked out as Elixir integers, and this makes the Feel.Type.NumberSet of them: the ranges of whole numbers that are one after the other are one interval. A set of numbers lies within decimal128, so a bound of more than 34 digits is widened to the nearest bound that is not, which holds the same numbers and more: a lower bound down, an upper bound up, to the end of the range of the numbers where it has to be.

iex> Feel.Analysis.IntegerSet.from_values([3, 1, 2, 7]) |> Feel.Type.NumberSet.format()
"[1..3], 7"
iex> Feel.Analysis.IntegerSet.from_ranges([{0, Integer.pow(10, 40)}]) |> Feel.Type.NumberSet.format()
"[0..max]"

Summary

Functions

The set of the whole numbers in ranges, {first, last} each.

The set of the whole numbers in a list.

Ranges of whole numbers in order, with those that overlap or are one after the other made one.

The numbers that the number alternatives of a type have, null aside, or :error if there is an alternative that is not a number. It is what a fact leaves of a property that is always a number (D-194).

The values of a list of whole numbers as the ranges of numbers that are one after the other.

Functions

from_ranges(ranges)

@spec from_ranges([{integer(), integer()}]) :: Feel.Type.NumberSet.t()

The set of the whole numbers in ranges, {first, last} each.

from_values(values)

@spec from_values([integer()]) :: Feel.Type.NumberSet.t()

The set of the whole numbers in a list.

merge(ranges)

@spec merge([{integer(), integer()}]) :: [{integer(), integer()}]

Ranges of whole numbers in order, with those that overlap or are one after the other made one.

iex> Feel.Analysis.IntegerSet.merge([{6, 9}, {1, 5}, {20, 21}, {8, 12}])
[{1, 12}, {20, 21}]

numbers(members)

@spec numbers([Feel.Type.Union.member()]) :: {:ok, Feel.Type.NumberSet.t()} | :error

The numbers that the number alternatives of a type have, null aside, or :error if there is an alternative that is not a number. It is what a fact leaves of a property that is always a number (D-194).

iex> {:ok, set} = Feel.Analysis.IntegerSet.numbers([{:number, Feel.Type.NumberSet.point(Decimal.new(3))}, :null])
iex> Feel.Type.NumberSet.format(set)
"3"
iex> Feel.Analysis.IntegerSet.numbers([:string])
:error

ranges(values)

@spec ranges([integer()]) :: [{integer(), integer()}]

The values of a list of whole numbers as the ranges of numbers that are one after the other.