Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Implementation of Map Function(s) in C #49

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

oduvall
Copy link

@oduvall oduvall commented Nov 30, 2023

Since C does not (at least easily) allow a way to pass arguments of an arbitrary type to a function, I decided that the simplest course of action was to split the map function into three separate map functions, each corresponding to a different type. Each function is identical in implementation, and only differs in the type of data it is able to manipulate. Each map function takes a function, applies it to each element of an array of input data, and then stores the results in an output array that is big enough to hold each result. A unit test for these functions is also included. This unit test maps some basic functions to some randomly generated data held in arrays of varying sizes, and compares the results with the correct outcome to ensure that each value was computed correctly.

… allow for functions to take arguments of arbitrary type, I decided the simplest course of action was to implement separate map functions for int, char, and float data types.
… allow for functions to take arguments of arbitrary type, I decided the simplest course of action was to implement separate map functions for int, char, and float data types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant