Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/licht1stein/cloj
Clojure inspired helper functions
https://github.com/licht1stein/cloj
Last synced: 1 day ago
JSON representation
Clojure inspired helper functions
- Host: GitHub
- URL: https://github.com/licht1stein/cloj
- Owner: licht1stein
- License: mit
- Created: 2021-01-27T21:34:58.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-09T14:54:57.000Z (almost 4 years ago)
- Last Synced: 2024-11-07T02:39:54.009Z (about 2 months ago)
- Language: Python
- Size: 18.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Clojure inspired helper functions for Python
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cloj)
![PyPI - License](https://img.shields.io/pypi/l/cloj)
![PyPI](https://img.shields.io/pypi/v/cloj?color=blue)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](https://python-poetry.org/) (always recommended):
```bash
poetry add cloj
```With pip:
```bash
pip install cloj
```Implemented:
* take/drop
* take_while/drop_while
* some
* nth, first, second, third, fourth, fifth, forty_second, last
* get-inSome examples:
```python
from cloj import take, droptake(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])
>> []
``````python
from cloj import first, second, third, fourth, fifth, forty_second, lastfirst([1, 2, 3])
>> 1last([1, 2, 3])
>> 3first([])
>> None
``````python
from cloj import get_insample = {"foo": {"bar": [0, {"spam": "target"}, 1]}}
get_in(sample, ["foo", "bar", 1, "spam"])
>>> "target"
```