A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
9
Task/Higher-order-functions/C/higher-order-functions-1.c
Normal file
9
Task/Higher-order-functions/C/higher-order-functions-1.c
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
void myFuncSimple( void (*funcParameter)(void) )
|
||||
{
|
||||
/* ... */
|
||||
|
||||
(*funcParameter)(); /* Call the passed function. */
|
||||
funcParameter(); /* Same as above with slight different syntax. */
|
||||
|
||||
/* ... */
|
||||
}
|
||||
5
Task/Higher-order-functions/C/higher-order-functions-2.c
Normal file
5
Task/Higher-order-functions/C/higher-order-functions-2.c
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
void funcToBePassed(void);
|
||||
|
||||
/* ... */
|
||||
|
||||
myFuncSimple(&funcToBePassed);
|
||||
13
Task/Higher-order-functions/C/higher-order-functions-3.c
Normal file
13
Task/Higher-order-functions/C/higher-order-functions-3.c
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
int* myFuncComplex( double* (*funcParameter)(long* parameter) )
|
||||
{
|
||||
long inLong;
|
||||
double* outDouble;
|
||||
long *inLong2 = &inLong;
|
||||
|
||||
/* ... */
|
||||
|
||||
outDouble = (*funcParameter)(&inLong); /* Call the passed function and store returned pointer. */
|
||||
outDouble = funcParameter(inLong2); /* Same as above with slight different syntax. */
|
||||
|
||||
/* ... */
|
||||
}
|
||||
7
Task/Higher-order-functions/C/higher-order-functions-4.c
Normal file
7
Task/Higher-order-functions/C/higher-order-functions-4.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
double* funcToBePassed(long* parameter);
|
||||
|
||||
/* ... */
|
||||
|
||||
int* outInt;
|
||||
|
||||
outInt = myFuncComplex(&funcToBePassed);
|
||||
5
Task/Higher-order-functions/C/higher-order-functions-5.c
Normal file
5
Task/Higher-order-functions/C/higher-order-functions-5.c
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
int* (*funcPointer)( double* (*funcParameter)(long* parameter) );
|
||||
|
||||
/* ... */
|
||||
|
||||
funcPointer = &myFuncComplex;
|
||||
Loading…
Add table
Add a link
Reference in a new issue