Magic List is a module that extends the built-in list type.
Project description
Magic List
Magic List is a module that extends the built-in list type.
Documentation · PyPI package · How to install · Notes for contributors and maintainers
[!NOTE] Its development is entirely test-driven: it is battery-tested and requires a test coverage of 100%. It also provides type stubs.
Installation
pip install magic-list
Examples
Fibonacci sequence
Let's write a function that given an integer n
, returns the fibonacci sequence up to the n
-th member.
For example, fibonacci_sequence(10)
would return [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
.
import operator
from magic_list import L, list
def fibonacci_sequence(n: int) -> list[int]:
# let's start by creating a list with the first two members, 0 and 1.
base = L[0, 1]
# we define a function that we will use to generate the next members of
# the sequence
def next_member(current: list[int]) -> int:
return current.take_right(2).sum()
return base.fill_right(next_member, n - 1)
[!NOTE] The
L[0, 1]
notation is a way to construct magic lists nicely.
Contributing
First of all, thank you for taking your time to participate in this project! 💕
You might want to check those:
- Code of Conduct · a document to set standards for respectful and inclusive behavior within the community
- README-dev.md · documentation to help you familiarize with Magic List's workflow
- Feature proposals · a list of the proposed features in the past, present and future
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file magic_list-2.4.0.tar.gz
.
File metadata
- Download URL: magic_list-2.4.0.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63e202e0bd373cd4ecf2b56706121ff366ca3f1aef14d6966e1a5ce58cb75d80 |
|
MD5 | 56fd14d7052c323b883fa6f224c78b2d |
|
BLAKE2b-256 | 84eaf6abff0c396aac58f754551f099a57a2e995cc3358c81cd41ec0f6f71b8f |
File details
Details for the file magic_list-2.4.0-py3-none-any.whl
.
File metadata
- Download URL: magic_list-2.4.0-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9b45988049b93c6d3705b9c438a2fdde35ff6651ac7c4bd4e57f6be8a251131 |
|
MD5 | 6b11e14af388799dbadbb861c500db06 |
|
BLAKE2b-256 | fda9156b0773f6c717f60138096ea6e9a0a06501f0ff6eaba38708f434df16d7 |