152#include <tclap/CmdLine.h>
159using namespace Aleph;
167 cout <<
"\n" << string(60,
'=') <<
"\n";
169 cout << string(60,
'=') <<
"\n\n";
185 cout <<
"The key feature of ah-zip-utils.H is mixing STL and Aleph containers!\n\n";
188 vector<int>
stl_ids = {101, 102, 103, 104};
194 cout <<
"STL vector<int> ids: [101, 102, 103, 104]" <<
endl;
195 cout <<
"STL list<string> names: [Juan, Maria, Carlos, Ana]" <<
endl;
196 cout <<
"Aleph DynList<double>: [85.5, 92.3, 78.0, 95.8]" <<
endl;
200 cout <<
"Zipping vector + list + DynList together:\n";
203 auto [id, name,
score] = it.get_curr();
204 cout <<
" ID " <<
id <<
": " <<
setw(8) << left << name
210 cout <<
"Using unified iterator:\n";
213 auto [id, name] = it.get_curr();
214 cout <<
" " <<
id <<
" -> " << name <<
endl;
229 cout <<
"STL vector quantities: [10, 25, 5, 30]" <<
endl;
230 cout <<
"Aleph DynList prices: [100, 50, 200, 25]" <<
endl;
254 cout <<
"\nAll orders:\n";
274 cout <<
"STL vector depts: [Huila, Nariño, Cauca, Tolima]" <<
endl;
275 cout <<
"Aleph DynList bags(k): [150, 85, 72, 65]" <<
endl;
283 cout <<
"Production reports:\n";
293 cout <<
"Major producers (>= 80k bags):\n";
303 cout <<
"Ranked by position:\n";
304 for (
const auto& r :
ranked)
319 cout <<
"STL list cities: [Bogota, Medellin, Cali, Barranquilla, Cartagena]" <<
endl;
320 cout <<
"Aleph DynList temps(C): [14, 24, 25, 28, 29]" <<
endl;
325 cout <<
"First 3 cities:\n";
332 cout <<
"Remaining cities:\n";
363 vector<int>
vec_a = {1, 2, 3, 4, 5};
366 cout <<
"STL vector a: [1, 2, 3, 4, 5]" <<
endl;
367 cout <<
"Aleph DynList b: [10, 20, 30, 40, 50]" <<
endl;
375 cout <<
"Running sum of (a[i] + b[i]):\n ";
383 cout <<
"vec_a and list_b same length? "
385 cout <<
"vec_a and short_vec same length? "
390 cout <<
"Zipped pairs: ";
393 auto [x,
y] = it.get_curr();
394 cout <<
"(" << x <<
"," <<
y <<
") ";
408 vector<double>
stl_prices = {25.0, 8.0, 12.0, 15.0};
410 cout <<
"STL vectors:\n";
411 cout <<
" products: [Cafe, Panela, Arroz, Frijol]" <<
endl;
412 cout <<
" prices: [25.0, 8.0, 12.0, 15.0]" <<
endl;
418 cout <<
"Converted to DynList<tuple>:\n";
430 cout <<
"Converted to std::vector<tuple>:\n";
451 cout <<
"Data from mixed sources:\n";
452 cout <<
" DB (vector): [Sofia, Andres, Valentina, Santiago, Isabella]" <<
endl;
453 cout <<
" Processed (DynList): [4.2, 3.8, 4.5, 3.5, 4.8] (Math)" <<
endl;
454 cout <<
" Input (list): [4.0, 4.2, 4.3, 3.9, 4.6] (Spanish)" <<
endl;
466 cout <<
"Student averages:\n";
467 for (
const auto& [name, avg] :
averages)
469 cout <<
" " <<
setw(10) << left << name <<
": "
481 cout <<
"Honors list:\n";
482 for (
const auto& t :
honors)
513 "Unified zip utilities example for Aleph-w.\n"
514 "Demonstrates mixing STL and Aleph containers in zip operations.",
520 "Run only specific section: mixed, predicates, transform, "
521 "utilities, advanced, conversion, practical, or 'all'",
522 false,
"all",
"section",
cmd
530 cout <<
"============================================================\n";
531 cout <<
" ALEPH-W UNIFIED ZIP UTILITIES EXAMPLE\n";
532 cout <<
" (Mix STL and Aleph containers!)\n";
533 cout <<
"============================================================\n";
556 cout <<
"\n" << string(60,
'=') <<
"\n";
557 cout <<
"Unified zip utilities demo completed!\n";
558 cout << string(60,
'=') <<
"\n\n";
562 catch (TCLAP::ArgException& e)
564 cerr <<
"Error: " << e.error() <<
" for argument " << e.argId() <<
endl;
569 cerr <<
"Error: " << e.what() <<
endl;
Unified zip operations for both STL and Aleph containers.
Dynamic singly linked list with functional programming support.
auto get_it() const
Return a properly initialized iterator positioned at the first item on the container.
Singly linked list implementations with head-tail access.
Main namespace for Aleph-w library functions.
auto uni_zip_scan_left(T init, Op &&op, const Containers &... cs)
Scan left - fold with intermediate results.
auto uni_zip_take(size_t n, const Containers &... cs)
Take first n tuples.
bool uni_zip_equal_length(const Containers &... cs)
Check if all containers have equal length.
bool uni_zip_exists(Pred &&pred, const Containers &... cs)
Check if predicate holds for any zipped tuple.
auto uni_zip_to_vector(const Containers &... cs)
Materialize zipped tuples into a vector.
bool uni_zip_none(Pred &&pred, const Containers &... cs)
Check if no tuple satisfies the predicate.
auto uni_zip_mapi(Op &&op, const Containers &... cs)
Map with index (mapi in ML).
T product(const Container &container, const T &init=T{1})
Compute product of all elements.
auto uni_zip_min(const Containers &... cs)
Get minimum tuple.
auto uni_zip_to_dynlist(const Containers &... cs)
Materialize a zipped view into a DynList of tuples.
std::string to_string(const time_t t, const std::string &format)
Format a time_t value into a string using format.
void uni_zip_for_each(Op &&op, const Containers &... cs)
Apply operation to each zipped tuple.
auto uni_zip_max(const Containers &... cs)
Get maximum tuple.
auto uni_zip_it(const Containers &... cs)
Get a unified zip iterator.
bool uni_zip_all(Pred &&pred, const Containers &... cs)
Check if predicate holds for all zipped tuples.
auto uni_zip_filter(Pred &&pred, const Containers &... cs)
Filter zipped tuples by predicate.
auto uni_zip_map(Op &&op, const Containers &... cs)
Map operation over zipped tuples.
auto uni_zip_drop(size_t n, const Containers &... cs)
Skip first n tuples, return the rest.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Lazy and scalable dynamic array implementation.
void print_subsection(const string &title)
void print_section(const string &title)
void demo_transformations()
void demo_mixed_containers()