Collections-C
Collections-C copied to clipboard
Reduce functions
It might be convinient for collections to have a fold/reduce function so that you may do something like this:
void fn(void *e1, void *e2, void *result)
{
int el1 = *((int*)e1);
int el2 = *((int*)e2);
*((int*) reslut) = el1 + el2;
}
...
// accumulate values of array into result
int reslut;
array_reduce(array, fn, &result);
do you mean a separate generic function which doesn't belong to any data structure? or a function for the dynamic array data structure only?
@ahmedabt
No, not a separate generic function. What I meant to say is that every sequential data structure should have a reduce
function that is specific to it. Array already has it implemented, but the Deque
, List
and SList
doesn't.
@srdja I can work on it as my first contribution to this project but it will take some time until I get familiar with the guidelines and code.
@ahmedabt That would be awesome!
Is this issue still up? I'd like to contribute with this
Hey @qequ, the issue is still up, and of course, you're welcome to contribute :)