Math sequence. Useful for calculations.
Note
This uses basic math and is incompatible with array frameworks like NumPy. We strive to keep it light.
from mathsq import MathSQ
array = MathSQ(
a1=10, # first item
d=2, # common difference
ln=10 # length ($n$ sequence)
)
This yields a sequence:
We can also create a MathSQ
from specifying the
array = MathSQ.from_n_assignment(
n=10,
value=100,
d=-1
)
This returns the array itself.
>>> array = array.setln(100)
Note
Out-of-bounds are not handled.
>>> array.n(5)
Note
Out-of-index is not handled.
>>> array.n_of(10)
Note
May return a float
.
>>> array.mid_n()
Note
Out-of-bounds are not handled.
>>> array.mid()
>>> # ...or
>>> array.M
Returns True
if the middle index exists.
>>> array.has_mid()
>>> array.sum()
>>> # ...or
>>> array.S
Note
Implementation not fully covered.
>>> array1 = array0 + 10 # array +/- float
>>> array1 -= array0 # array +/- array
>>> array1.a1
10
>>> array1 * 10
Find the closest
Restrictions:
or
or
>>> array0.where0()