Listrology
name is suggested by our good friend chatgpt
Listrology extends the functionality of lists
Installation
pip install listrology
Usage
Listrology contains a subclass of list which provides a number of methods that are useful
from listrology import List
assert List([1, 2, 3]) == [1, 2, 3]
Square bracket prefix is also supported
from listrology import List
assert List[4, 5, 6] == [4, 5, 6]
There is also a shorthand constructor
from listrology import L, List
assert L[7, 8, 9] == List[7, 8, 9] == [7, 8, 9]
Some methods include
mylist = L[0, 1, 2, 3, 4, 5, 6]
mylist.foreach(print)
mylist.reject(lambda x: x == 2)
mylist.overwrite(target=1, start=5, end=7)
mylist.first(lambda x: x % 2 == 1)
mylist.fill("yo", 2, 4)
mylist.rotate(1)
mylist.rotate(2)
listrology's lists supports method chaining (each method produces a new instance)
volcano_heights = L[412, 399, 276, 591, 482, 451, 521, 529, 521, 426, 511, 426, 426]
result = volcano_heights.filter(lambda x: 400 <= x <= 525).unique().sort()