diff --git a/m-algo.h b/m-algo.h index 3b083e5d..f910fd3b 100644 --- a/m-algo.h +++ b/m-algo.h @@ -202,7 +202,8 @@ //TODO: const_iterator & CM_EACH missing... //TODO: Algorithm missing -// nth_element, ... +// nth_element, reduce, find_last, find_if, count_if, ... +//TODO: Copy from a container to another if condition. #define ALGOI_MAP(container, cont_oplist, func) \ for M_EACH(item, l, cont_oplist) { \ @@ -211,7 +212,7 @@ #define ALGOI_MAP_ARG(container, cont_oplist, func, ...) \ for M_EACH(item, l, cont_oplist) { \ - func(__VA_ARGS, *item); \ + func(__VA_ARGS__, *item); \ } \ #endif diff --git a/tests/test-malgo.c b/tests/test-malgo.c index abe03044..105435d4 100644 --- a/tests/test-malgo.c +++ b/tests/test-malgo.c @@ -28,6 +28,11 @@ static void test_list(void) list_int_push_back (l, 17); assert( algo_list_count(l, 17) == 2); assert( algo_list_count(l, -1) == 0); + +#define f(x) assert((x) >= 0 && (x) < 100); + ALGO_MAP(l, LIST_OPLIST(int), f); +#define g(y, x) assert((x) >= 0 && (x) < y); + ALGO_MAP(l, LIST_OPLIST(int), g, 100); list_int_clear(l); }