|
| template<typename Op , typename Container > |
| void | Aleph::uni_for_each (Op &&op, const Container &c) |
| | Apply operation to each element (for_each).
|
| |
| template<typename Op , typename Container > |
| void | Aleph::uni_for_each_indexed (Op &&op, const Container &c) |
| | Apply operation to each element with index.
|
| |
| template<typename Op , typename Container > |
| auto | Aleph::uni_map (Op &&op, const Container &c) |
| | Map operation - transform each element.
|
| |
| template<typename Op , typename Container > |
| auto | Aleph::uni_mapi (Op &&op, const Container &c) |
| | Map with index (mapi in ML).
|
| |
| template<typename Pred , typename Container > |
| auto | Aleph::uni_filter (Pred &&pred, const Container &c) |
| | Filter elements satisfying predicate.
|
| |
| template<typename Pred , typename Container > |
| auto | Aleph::uni_filteri (Pred &&pred, const Container &c) |
| | Filter with index (filteri in ML).
|
| |
| template<typename T , typename Op , typename Container > |
| T | Aleph::uni_foldl (T init, Op &&op, const Container &c) |
| | Left fold (foldl) - reduce from left to right.
|
| |
| template<typename T , typename Op , typename Container > |
| T | Aleph::uni_reduce (T init, Op &&op, const Container &c) |
| | Alias for uni_foldl.
|
| |
| template<typename T , typename Op , typename Container > |
| std::vector< T > | Aleph::uni_scan_left (T init, Op &&op, const Container &c) |
| | Scan left - fold with all intermediate results.
|
| |
| template<typename Pred , typename Container > |
| bool | Aleph::uni_all (Pred &&pred, const Container &c) |
| | Check if all elements satisfy predicate.
|
| |
| template<typename Pred , typename Container > |
| bool | Aleph::uni_exists (Pred &&pred, const Container &c) |
| | Check if any element satisfies predicate.
|
| |
| template<typename Pred , typename Container > |
| bool | Aleph::uni_any (Pred &&pred, const Container &c) |
| | Alias for uni_exists.
|
| |
| template<typename Pred , typename Container > |
| bool | Aleph::uni_none (Pred &&pred, const Container &c) |
| | Check if no element satisfies predicate.
|
| |
| template<typename Pred , typename Container > |
| auto | Aleph::uni_find (Pred &&pred, const Container &c) |
| | Find first element satisfying predicate.
|
| |
| template<typename Pred , typename Container > |
| std::optional< size_t > | Aleph::uni_find_index (Pred &&pred, const Container &c) |
| | Find index of first element satisfying predicate.
|
| |
| template<typename Op , typename Container > |
| auto | Aleph::uni_find_mapi (Op &&op, const Container &c) |
| | Find and map with index (find_mapi in ML).
|
| |
| template<typename T , typename Container > |
| bool | Aleph::uni_mem (const T &target, const Container &c) |
| | Check if element exists in container (mem in ML).
|
| |
| template<typename Pred , typename Container > |
| size_t | Aleph::uni_count (Pred &&pred, const Container &c) |
| | Count elements satisfying predicate.
|
| |
| template<typename Container > |
| size_t | Aleph::uni_length (const Container &c) |
| | Get container length.
|
| |
| template<typename Container > |
| auto | Aleph::uni_take (size_t n, const Container &c) |
| | Take first n elements.
|
| |
| template<typename Container > |
| auto | Aleph::uni_drop (size_t n, const Container &c) |
| | Drop first n elements, return the rest.
|
| |
| template<typename Pred , typename Container > |
| auto | Aleph::uni_take_while (Pred &&pred, const Container &c) |
| | Take elements while predicate is true.
|
| |
| template<typename Pred , typename Container > |
| auto | Aleph::uni_drop_while (Pred &&pred, const Container &c) |
| | Drop elements while predicate is true, return the rest.
|
| |
| template<typename Container > |
| auto | Aleph::uni_first (const Container &c) |
| | Get first element.
|
| |
| template<typename Container > |
| auto | Aleph::uni_last (const Container &c) |
| | Get last element.
|
| |
| template<typename Container > |
| auto | Aleph::uni_nth (size_t n, const Container &c) |
| | Get n-th element.
|
| |
| template<typename Container > |
| auto | Aleph::uni_min (const Container &c) |
| | Get minimum element.
|
| |
| template<typename Container > |
| auto | Aleph::uni_max (const Container &c) |
| | Get maximum element.
|
| |
| template<typename Container > |
| auto | Aleph::uni_min_max (const Container &c) |
| | Get both min and max in a single pass.
|
| |
| template<typename Container > |
| auto | Aleph::uni_sum (const Container &c) |
| | Sum all elements.
|
| |
| template<typename Container > |
| auto | Aleph::uni_product (const Container &c) |
| | Product of all elements.
|
| |
| template<typename Pred , typename Container > |
| auto | Aleph::uni_partition (Pred &&pred, const Container &c) |
| | Partition elements by predicate.
|
| |
| template<typename Container1 , typename Container2 > |
| auto | Aleph::uni_concat (const Container1 &c1, const Container2 &c2) |
| | Concatenate two containers.
|
| |
| template<typename Container > |
| auto | Aleph::uni_flatten (const Container &c) |
| | Flatten a container of containers.
|
| |
| template<typename Op , typename Container > |
| auto | Aleph::uni_flat_map (Op &&op, const Container &c) |
| | Flat map - map then flatten.
|
| |
| template<typename Container > |
| auto | Aleph::uni_distinct (const Container &c) |
| | Remove all duplicates (keeps first occurrence).
|
| |
| template<typename Key , typename Container > |
| auto | Aleph::uni_group_by (Key &&key, const Container &c) |
| | Group elements by key function.
|
| |
| template<typename Container > |
| auto | Aleph::uni_tally (const Container &c) |
| | Count occurrences of each element (frequency count).
|
| |
| template<typename Container > |
| auto | Aleph::uni_to_vector (const Container &c) |
| | Convert container to std::vector.
|
| |
| template<typename Container1 , typename Container2 > |
| bool | Aleph::uni_equal (const Container1 &c1, const Container2 &c2) |
| | Check equality of two containers.
|
| |
| template<typename Container1 , typename Container2 > |
| int | Aleph::uni_compare (const Container1 &c1, const Container2 &c2) |
| | Compare two containers lexicographically.
|
| |
Unified functional programming utilities for both STL and Aleph containers.
This header provides functional programming operations that work seamlessly with any container type:
- STL containers: std::vector, std::list, std::deque, std::set, etc.
- Aleph containers: DynList, DynArray, DynDlist, DynSetTree, etc.
The implementation uses type traits to automatically detect the container type and apply the appropriate iteration method.
Usage Example:
#include <vector>
std::vector<int> stl_vec = {1, 2, 3, 4, 5};
DynList<int> aleph_list = {10, 20, 30, 40, 50};
auto stl_squares =
uni_map([](
int x) {
return x * x; }, stl_vec);
auto aleph_squares =
uni_map([](
int x) {
return x * x; }, aleph_list);
int aleph_sum =
uni_foldl(0, std::plus<int>{}, aleph_list);
Unified functional programming utilities for both STL and Aleph containers.
Singly linked list implementations with head-tail access.
auto uni_map(Op &&op, const Container &c)
Map operation - transform each element.
auto stl_sum(const Container &c)
Sum all elements.
T uni_foldl(T init, Op &&op, const Container &c)
Left fold (foldl) - reduce from left to right.
- Note
foldr is only available for STL containers with reverse iterators.
- Author
- Leandro Rabindranath Leon
Definition in file ah-uni-functional.H.