In our $intervals array, each interval should contain two numbers [a, b].
We can optionally add two booleans to an interval, signifying the openness
of a and b, respectfully (true means open, false means closed). If boolean
arguments are not supplied, the interval will be assumed to be closed.
Examples:
1. [0, 2, true, false] means an interval from 0 to 2, where 0 is open
(exclusive) and 2 is closed (inclusive).
2. [-10, 10] means an closed (inclusive) interval from -10 to 10
A number of conditions need to be met for a piecewise function:
o We must provide the same number of intervals as callback functions
o Each function in our $functions array needs to be callable
o Each interval must contain precisely 2 numbers, optionally 2
o An interval defined as a point (e.g. [2, 2]) must be closed at both ends
o The numbers in an interval must be increasing. Given [a, b] then b >= a.
o Two intervals cannot overlap. This means that if two intervals share
a start and end-point, the point must be closed on both sides. Also,
we cannot start or end an interval in the middle of another interval.