Table of Contents
Prologue
I like Haskell, also hope some of the prelude functions in Haskell can be used in Python.
Wish you enjoy coding with nalude.
Nalude
Nalude is a standard module, which is inspired by Haskell's Prelude. Thus, nalude is also a library of functional programming.
Nalude doesn't explicitly distinguish between Applicative's or monadic function since they are not well differentiated in the basic structure of Python. Of course, the main reason is that I am too fresh.
The following functions, Nalude tries to implement:
- Folds and Traversals
- Lists
- Miscellaneous
- Specials
- Strings
- Tuples
- Zip and Unzip
At the same time, it also implements some functions which are only available in Python and are included in `extra`.
Structure of Functions
Folds and Traversals
- foldr(f: Callable[[b, a], b], init: b, t: Sequence[a]): Right-associative fold of a sequence.
- foldl(f, init, t): Left-associative fold of an iterable. The same as
reduce. - foldr1(f, t): A variant of foldr without base case.
- foldl1(f, t): A variant of foldl without base case.
- product(nums): Computes the product of the numbers.
- (HELP WANTED) traverse: Map each element of a structure to an action, evaluate these actions from left to right, and collect the results.
- (HELP WANTED) sequence: Evaluate each actions in the structure from left to right, and collect the results.
Lists
- head(xs): Extract the first element of an iterable.
- last(xs): Extract the last element of an iterable.
- null(xs): Test whether the sequence is empty.
- Infinite lists
-
iterate(f, x): Yield a tuple of repeated applications of f to x.
-
repeat(x): Repeat x.
-
replicate(n, x): Return a list of length n with x the value of every element.
-
cycle(xs): Tie an iterable to infinite circuler one.
-
Sublists
- tail(xs): Extract the elements after the head of a list.
- init(xs): Extract all the elements of an iterable except the last one.
- take(n, xs): Return the first n elements of sequence xs.
- drop(n, xs): Return the remaining elements of xs after the first n elements.
- splitat(n, xs): Return a tuple where the first element is xs prefix of length n and second element is the remainder of the sequence xs.
- takewhile(p, xs): Return the longest prefix of xs of elements that satisfy predicate p.
- dropwhile(p, xs): Return the suffix remaining after takewhile(p, xs).
- (LAZY ONE HELP WANTED) span(p, xs): Equal to (takewhile(p, xs), dropwhile(p, xs)).
- (LAZY ONE HELP WANTED) break_(p, xs): Equal to (takewhile(not_(p), xs), dropwhile(not_(p), xs)).
-
Miscellaneous
- id_(x): Identity function.
- const(x, _): Evaluates to x for all inputs.
- o(f1, f2): (.) Function composition
- flip(f): Flip takes its two arguments into the reverse order of f.
- until(p, f, x): Yield the result of applying f until p holds.
String
- lines(s): Break up a string into a list of strings at newline characters.
- unlines(xs): The inverse operation of lines, append a newline to each.
- words(s): Break a string up into a list of words, which were delimited by white space.
- unwords(xs): The inverse operation of words, join words with space.
Specials
- not_(f): Boolean "not".
- all_(p, xs): Determine whether all elements of the structure satisfy the p.
- any_(p, xs): Determine whether sny elements of the structure satisfies the p.
- concat(xss): The concatenation of all the elements of a container of Sequences.
- concatmap(f, xss): Map a function over all the elements of a container and concatenate the resulting lists.
Tuples
- fst(t): Extract the first component of a tuple.
- snd(t): Extract the second component of a tuple.
- curry(f, a, b): Converts an uncurried function to a curried function.
- uncurry(f, ab@(a, b)): Converts a curried function to a function on pairs.
Zip and Unzip
- zipwith(f, *seqs): Zipwith is map(f, zip), but f accept separate args instead of tuple
- unzip(pairs): Transform an iterable of pairs into a tuple of sequence. (Not lazy)
Extra
- flatten(xs,*,ignore=(dict,)): Flatten iterables of iterable to a single iterable. It will
ignore instances in
ignoretuple.
Get Start
Install
pip install nalude
Epoligue
History
Version 0.3.0
- Data:
- Add: - Custom ignore when flatten iterable.
Version 0.2.0
- Data:
- Add: - flatten in extra.
Version 0.1.0
- Data:
- Commemorate Version: First Release.
Metadata
Release files for nalude 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nalude-0.3.0.tar.gz | 18.1 kB | Without provenance | Details for nalude-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nalude-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for nalude-0.3.0-py3-none-any.whl |
Total release size: 75.8 kB
Release files / nalude-0.3.0.tar.gz
| Download URL | nalude-0.3.0.tar.gz |
|---|---|
| Size | 18.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4da2bade4488c6e6c7934e4321ed4f4d75964174c33a79d8417aaa1192c4edf4
|
|
BLAKE2b-256 checksum How to use checksums |
c87db937aab0e9a5a41a949f363a361ac4cbddfc7c30fc158d934913c6ec0cac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.0a2 CPython/3.7.2 Darwin/18.2.0
|
Release files / nalude-0.3.0-py3-none-any.whl
| Download URL | nalude-0.3.0-py3-none-any.whl |
|---|---|
| Size | 57.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5eb73cf683d1c278592bf25f134526ddd5705246c0c73e068ec9770ad25ba833
|
|
BLAKE2b-256 checksum How to use checksums |
5309d8c56d47fbc6676aa3467751b859d32a5022688238b0b0660433e3c898f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.0a2 CPython/3.7.2 Darwin/18.2.0
|
Security for nalude 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.