Skip to main content

Clojure inspired helper functions

Project description

Clojure inspired helper functions for Python

PyPI - Python Version PyPI - License PyPI

This is a small library with Clojure inspired helper functions. It uses only the standard library, without any external dependencies.

The goal is to implement replicas of the Clojure funcs that I admire.

Installation

With poetry (always recommended):

poetry add cloj

With pip:

pip install cloj

Implemented:

  • take/drop
  • take_while/drop_while
  • some
  • nth, first, second, third, fourth, fifth, forty_second, last
  • get-in

Some examples:

from cloj import take, drop

take(3, [1, 2, 3, 4, 5])
>> [1, 2, 3]

drop(3, [1, 2, 3, 4, 5])
>> [4, 5]

drop (100, [1, 2, 3, 4, 5])
>> []
from cloj import first, second, third, fourth, fifth, forty_second, last

first([1, 2, 3])
>> 1

last([1, 2, 3])
>> 3

first([])
>> None
from cloj import get_in

sample = {"foo": {"bar": [0, {"spam": "target"}, 1]}}
get_in(sample, ["foo", "bar", 1, "spam"])
>>> "target"

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

cloj-0.2.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

cloj-0.2.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file cloj-0.2.0.tar.gz.

File metadata

  • Download URL: cloj-0.2.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.7.10 Linux/5.4.0-1040-azure

File hashes

Hashes for cloj-0.2.0.tar.gz
Algorithm Hash digest
SHA256 abe7d82d6c500e980197b3e4d0cbdc4fe0d11f7221b5513ea383cf98c2902be9
MD5 189f6184c293bd5b95baae47cbabb768
BLAKE2b-256 67f45ff25b52d172b3e8b40fc7a1995d6767b0ec15fc2ed365f66814452bdd58

See more details on using hashes here.

File details

Details for the file cloj-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: cloj-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.7.10 Linux/5.4.0-1040-azure

File hashes

Hashes for cloj-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 216ff9cd1747c2c43b946a548ca987b8c2aea8c85b0ffd3669cebc212c1f7649
MD5 84413b65a985dad58de058f1fc223fdb
BLAKE2b-256 7c949260bb2a1aead521086c29c752f0f40461a21d7e027b156c5036ef663f7b

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