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

Executable XML users challenge

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-08 5:01

provide any LISP macro with clear explanation of its structure and function
that is :
1.concise (max 10 lines)
2.does not have a C equivalent(at least not anything above 100 lines)
3.does not use any libraries or imported complex functions which are not in C
If you provide an exact explanation/commentary on what it does i'll try to make a C solution which
is equivalent to LISP one. If i fail to do so, LISP wins, if i provide a solution you can make another macro.
If all examples in the thread are provide with C equivalents, LISP loses.

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-08 6:44

>>22
I don't see anything wrong with the C code, here is equivalent macro
#define sort(array,function)   qsort(array, sizeof(array)/sizeof(array[0]), sizeof(array[0]),function)
#include <stdio.h>
#include <stdlib.h>
int comparator(const void *num1, const void *num2) {
    return *(const int *)num1 - *(const int *)num2;}
int comparator2(const void *num1, const void *num2) {
    return *(const int *)num2 - *(const int *)num1;}


int main(int argn, char *args[]){
  int arr1[] = {6, 5, 8, 1, 10, 4};
  int arr2[] = {6, 5, 8, 1, 10, 4};
  int i;
sort(arr1,comparator);
   for(i=0; i<(int)(sizeof(arr1)/sizeof(int)); i++) printf("%d ", arr1[i]);
  printf("\n");
sort(arr2,comparator2);
  for(i=0; i<(int)(sizeof(arr2)/sizeof(int)); i++) printf("%d ", arr2[i]);

  return 0;
}

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