Skip to main content

A small package introducing a new way to use higher order functions with lists

Project description

Qwery List

QList is a small library introducing a new way to use higher order functions with lists, with lazy evaluation. It also aims to address ugly python list methods such as map, filter and reduce. Whoever invented this:

xs = ['1', '2', '3', '4']
s = reduce(lambda acc, x: acc + x, filter(lambda x: x < 3, map(int, xs)), 0)

must reevaluate their life choices (yes, I am being cocky and most likely dumdum) but listen to me first and look what the world of lazy evaluation has to offer!

xs = QList([1, 2, 3, 4])
s = xs.map(int).filter(lambda x: x < 3).fold(lambda acc, x: acc + x, 0)

As a bonus you get len() method, so no longer will you be forced to wrapp your lists in this type of code len(xs) and simply call xs.len() (I understand it is negligibly slower but look how much nicer it looks!)

Quick tutorial

Let's say we want to read numbers from a file and choose only the even ones. No problem at all!

with open('path/to/file.txt', 'r') as file:
    qlist = QList(file.readlines())
even = qlist.map(int).filter(lambda x: x % 2 == 0).collect()

Why is there this collect at the end? Because all operations on the QList are lazy evaluated, so in order to finally apply all the operations you need to express that. (Eager evaluated module coming soon...)


Side note

I hereby announce that UwU, Qwery Listwu

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

qwlist-0.1.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

qwlist-0.1.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file qwlist-0.1.0.tar.gz.

File metadata

  • Download URL: qwlist-0.1.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for qwlist-0.1.0.tar.gz
Algorithm Hash digest
SHA256 636f7a613d443d1d188c9aa15ef816d0d60e1cc77bbe610a96e8c2975f1db6f4
MD5 39923b0d395fe00da2667f64e6fa7760
BLAKE2b-256 3a68f01e987b0e4a682f620274f8f9d128c40333ace697c083dbb35e877a1ec4

See more details on using hashes here.

File details

Details for the file qwlist-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: qwlist-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for qwlist-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc164dd2daceac06e4ad349fdafb89ea3e59912ec1615af3f28b494b16ae4077
MD5 54c62497a038a746c77a89d6db8e674c
BLAKE2b-256 cb074cd075e015fb68c597e86bff1d06828415f91bb1703f59ddec57a1ee1dd4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page