Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Reduce functions #19

Open
srdja opened this issue Mar 26, 2016 · 6 comments
Open

Reduce functions #19

srdja opened this issue Mar 26, 2016 · 6 comments

Comments

@srdja
Copy link
Owner

srdja commented Mar 26, 2016

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);
@aeltawela
Copy link

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?

@srdja
Copy link
Owner Author

srdja commented May 25, 2018

@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.

@aeltawela
Copy link

@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.

@srdja
Copy link
Owner Author

srdja commented May 26, 2018

@ahmedabt That would be awesome!

@qequ
Copy link
Contributor

qequ commented Jan 11, 2022

Is this issue still up? I'd like to contribute with this

@srdja
Copy link
Owner Author

srdja commented Jan 13, 2022

Hey @qequ, the issue is still up, and of course, you're welcome to contribute :)

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants