Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Common Lisp in C

Name: Anonymous 2012-10-03 17:23

Lets write Common Lisp functions in generic C code.


/* (map #'func array) => map(array,length_of_array,sizeof(array),function_pointer) */
void *map(void *base,size_t len,size_t elemnsize, void (*func)(void *,void *)) {
  void *b = malloc(elemsize*len);
  size_t i;
  for(i=0;i<len;++i){
    func(b+(elemsize*1),base);
    base += elemsize;
  }
  return b;
}

Name: Anonymous 2012-10-04 12:40

Or you can just write a destructive version of map and stop being autistic .

I highly doubt a single map function would act as an API hidden from the 'user' to begin with.

In the end your issue come down to a codemonkey that didnt read the api docs or source code to realize he needs to free the reault.result with that being said i doubt he would have even remembered to free his own allocations within the same scooe.scope

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List