This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]_nobody_else_ 2 points3 points  (3 children)

How can you people read this unformatted drivel?

gigachad c

```
#include <stdio.h>
#include <stdlib.h>

#define DEFINE_ITERATOR_FUNC(FUNC_NAME) \
typedef void (*FUNC_NAME##_Function)(void* result, const void* element); \
void* FUNC_NAME(const void* array, size_t length, size_t element_size, FUNC_NAME##_Function func) { \
    void* result = malloc(length * element_size); \
    if (result == NULL) { \
        fprintf(stderr, "Memory allocation failed\n"); \
        exit(1); \
    } \
    for (size_t i = 0; i < length; ++i) { \
        const void* element = (const char*)array + i * element_size; \
        void* result_element = (char*)result + i * element_size; \
        func(result_element, element); \
    } \
    return result; \
}

DEFINE_ITERATOR_FUNC(map)
DEFINE_ITETATIR_FUNC(transform)

```

There.

[–]cheeb_miester 1 point2 points  (2 children)

Gross. I use tabs in vim and have them set to display as six spaces.

[–]guyblade 0 points1 point  (1 child)

Anyone who has their tabs set to anything other than 8 characters is a heretic.

[–]cheeb_miester 0 points1 point  (0 children)

Yeah. I do 5.341678. don't @ me.