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 10:02

>>58
int i;
#define STDMAIN main(int argc,char**argv){;
#define STDEND ;return 0;};
#define cs4p const int*
#define cf8p const double*
#define sort(array,function) qsort((void*)array, sizeof(array)/sizeof(array[0]),sizeof(array[0]),function)
#define printints(array) ;for(i=0;i<(sizeof(array)/sizeof(array[0]));i++){printf("%d ",array[i]);};puts("");
#define printdoubles(array) ;for(i=0;i<(sizeof(array)/sizeof(array[0]));i++){printf("%f ",array[i]);};puts("");
#define printevens(array) ;for(i=0;i<(sizeof(array)/sizeof(array[0]));i++){if(!(array[i]&1))printf("%d ",array[i]);};puts("");
#define printodds(array) ;for(i=0;i<(sizeof(array)/sizeof(array[0]));i++){if((array[i]&1))printf("%d ",array[i]);};puts("");
#define sortpd(array,function) sort(array,function);printdoubles(array);
#define sortp(array,function) sort(array,function);printints(array);

#include <stdio.h>
#include <stdlib.h>
int cmpn(cs4p num1,cs4p num2){return *num1-*num2;}
int cmpr(cs4p num1,cs4p num2){return *num2-*num1;}
int dcmpn(cf8p a,cf8p b){return (*a>*b)- (*a<*b);}

STDMAIN;//i'm not going to re/allocate anything useless at run-time.
int intarr[]={6,5,9,2,1,8};
double doublearr[]={2.0,0.0,4.5};
sortpd(doublearr,dcmpn);
sort(intarr,cmpn);
printodds(intarr);
printevens(intarr);
puts("hello world");
STDEND

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