Python library that chains functions with dots
A python library that lets you chain together functions with dots into pipelines. Looks like jquery to me, is actually taken from Scala:
from functional import seq
seq([[1, 1], [2, 3], [5, -1]]).flat_map(lambda x: x).sum()
I wonder how it handles errors in the chain...
List of supported functions
List to List
- init: get everything except last element
- tail: get everything except first element
- inits: get subsequent inits
- tails: get subsequent tails
- drop: drop first n elements
- drop_while: drop first elements using f
- take: take first n elements
- take_while: take first elements using f
- map: map f onto sequence
- filter: filter sequence by f
- filter_not: filter sequence by not f
- reverse: reverse sequence
- distinct: return set of unique/distinct elements
- flatten
- flat_map
- group_by
- enumerate, zip_with_index
- partition
- slice
- zip
- sorted
List of (Key, Value) to List
- reduce_by_key
- group_by_key
List to Value
- head, first: get first element
- head_option: get first element or None
- last: get last element
- last_option: get last element or None
- reduce: reduce sequence using f
- fold_left
- fold_right
- count, len, size: get count of sequence
- any
- all, for_all
- max, max_by
- min, min_by
- find
- empty
- non_empty
- string: similar to mkString
- sum
Conversion to other types
- set
- list
- to_dict