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: Anonymous 2011-12-08 5:04

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

>>2
Well, main selling point of LISP = Powerful macro system. Show some of that power.

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

If provided C macro is obviously inferior it would show how superior and elegant LISP syntax is(wtihout judgement on performance):
If there is no clear way to accomplish some LISP macro it would show a deficiency in C
If the LISP macro is easily translated into C preprocessor, it would make C superior.
If the LISP macro requires a complex C hack or multiple C function calls, this would also showcase simplicity of LISP.

Name: Anonymous 2011-12-08 5:32

Regular expression matcher macro, which compiles to machine code.

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

>>5
provide LISP code with clear and exact explanation of what it does.
Don't provide abstract examples or claims or LISP superiority.

Name: Anonymous 2011-12-08 5:39

>>3
nope, it is elegancy. writing in LISP more like an art than programming.

also not sure about what you mean by "lines". LISP code is basically a single line.

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

>>5
also, C file(with regex library) can produce a C output file(fprintf result strings) which would be compiled as second stage
system("compiler -flags output.c")
Its not complex just awkward.

Name: Anonymous 2011-12-08 5:45

hey frozenfurfag if you want people to like you here do something awesome like port the code into a simple turing-equivalent cellular automaton or something.
no one cares if you can rewrite code in C.

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

>>5 it would work like this:
1.C code produces Output.C using regexes and string parsing functions.
2.C code calls compiler to compile output.c to output.exe
3.control is transffered to output.exe,C code stops.

Name: Anonymous 2011-12-08 5:56

>>6
When you pay me enough.

Name: Anonymous 2011-12-08 5:57

Name: Anonymous 2011-12-08 5:58

>>10
Feel the elegancy of raw C!

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

>>13
In some cases you may want to compile and load dynamically object files like tiny .dll's or .o files into the parent process executable space,
but they all require calling the compiler at least once(to produce the executable object file: it may be even 1 function long).
Anyway i've not seen any clear example of LISP macro which does something exclusive to LISP, so i could compare and propose an equivalent(which could even not use regexes or some complex features, just C code).

Name: Anonymous 2011-12-08 6:13

>>14
exclusive to LISP
>>2

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

>>15
Not that, show something which is requiring to writing a page of code to work to replicate a line of LISP.
Even better: show equivalent "ugly" C code vs "elegant" LISP code, so i could try to rewrite it in far less space.

Name: Anonymous 2011-12-08 6:28

Inb4 Frozen writes a horrible LISP interpreter inside C

Name: Anonymous 2011-12-08 6:30

Executable XML users challenge?

Name: Anonymous 2011-12-08 6:31

It's not spelled ``LISP''.

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

>>17
I wouldn't write any run-time based code. Its very counterproductive to achieving any performance.
Compilation always has an advantage since it it not limited in time: a 1 hour compilation of an executable will outperform interpreted file which cannot spend time to interpret and optimize much, since it has to run at real-time.

Name: Anonymous 2011-12-08 6:34

Name: Anonymous 2011-12-08 6:35

>>16

(sort '(6 5 8 1 10 4) #'<)
(sort '(6 5 8 1 10 4) #'>)



#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;
  qsort(arr1, sizeof(arr1)/sizeof(int), sizeof(int), comparator);
  for(i=0; i<(int)(sizeof(arr1)/sizeof(int)); i++) printf("%d ", arr1[i]);
  printf("\n");
  qsort(arr2, sizeof(arr2)/sizeof(int), sizeof(int), comparator2);
  for(i=0; i<(int)(sizeof(arr2)/sizeof(int)); i++) printf("%d ", arr2[i]);

  return 0;
}

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;
}

Name: Anonymous 2011-12-08 6:50

>>23
except that it is ugly as shit and huge comparing to lisp version? seriously, in lisp you simply say "sort" and give an array and a comparison operator and viola. in C you are surrounded with type casting, stupid tricks like sizeof a/sizeof *a, had to redefine a simple comparison operator etc

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

is it pretty now?
#define STDMAIN int main(int argc,char**argv){;
#define STDEND ;return 0;};
typedef unsigned int u4;
u4 i;
#define sort(array,function)   qsort(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("");
#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;}
STDMAIN
  u4 arr1[] = {6, 5, 8, 1, 10, 4};
  u4 arr2[] = {6, 5, 8, 1, 10, 4};
sort(arr1,comparator);printints(arr1);
sort(arr2,comparator2);printints(arr2);
 STDEND

Name: Anonymous 2011-12-08 6:54

>>25
it hurts to look

Name: Anonymous 2011-12-08 6:58

>>25
I lol'd hard. It's been FrozenVoid'd

Name: Anonymous 2011-12-08 7:12

>>22
You forgot to bring your ENTERPRISE C MACRO SYSTEM FOR SYNERGISTIC LEVERAGE.

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

#include "CUDDER.h"

int main (void) {
  int array_1 [] = {6, 5, 8, 1, 10, 4};
  int array_2 [] = {6, 5, 8, 1, 10, 4};

  sort(array_1,
       lambda (const void * a, const void * b) {
     return *(const int *) a - *(const int *) b;
       } lambda_end);

  puts("first:");
  foreach (int i, array_1) {
    printf("%d\n", i);
  } foreach_end;

  sort(array_2,
       lambda (const void * a, const void * b) {
     return *(const int *) b - *(const int *) a;
       } lambda_end);

  puts("second:");
  foreach (int i, array_2) {
    printf("%d\n", i);
  } foreach_end;

  return 0;
}


CUDDER.h
#ifndef __CUDDER_H
#define __CUDDER_H

#include <stdlib.h>

#define lambda(...)                \
  ({                        \
    int (*__lambda_fptr)(__VA_ARGS__);        \
    int   __lambda (__VA_ARGS__)

#define lambda_end                \
    __lambda_fptr = __lambda;            \
  })

#define foreach(var, array)                \
  ({                            \
    int __foreach_i;                    \
    for (__foreach_i = 0;                \
     __foreach_i < sizeof(array)/sizeof(array[0]);    \
     __foreach_i++) {                \
      var = array[__foreach_i];

#define foreach_end                \
    }                        \
  })

#define sort(array, comparator)            \
  qsort(array,                    \
    sizeof(array) / sizeof(array[0]),    \
    sizeof(array[0]),            \
    comparator)

#endif

Name: Anonymous 2011-12-08 7:39

C is PIG DISGUSTING.

I'm happy to let the C autists squabble about performance. Just keep hacking away, cretins - make my LISP interpreter grow stronger!

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

//void.h 610 bytes
#define STDMAIN int main(int argc,char**argv){;
#define STDEND ;return 0;};
#define cv0p  const void*
#define cs4p const int*
#define is4 inline int
#define sort(array,function)   qsort(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 sortp(array,function)  sort(array,function);printints(array);
#include <stdio.h>
#include <stdlib.h>
is4 cmpn(cv0p num1, cv0p num2){return *(cs4p)num1-*(cs4p)num2;}
is4 cmpr(cv0p num1, cv0p num2){return *(cs4p)num2-*(cs4p)num1;}
//main.c 78 bytes
STDMAIN int i;int arr[]={6,5,8, 1,10,4};sortp(arr,cmpn);sortp(arr,cmpr);STDEND

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

Any other LISP macro which is hard to make in C?

Name: Anonymous 2011-12-08 8:11

>>31
I still can't see an elegant replacement to sort.

Name: Anonymous 2011-12-08 8:21

>>32
Are you blind? Legit question.

Name: Anonymous 2011-12-08 8:22

>>33
Yes, after seeing >>30 I carved my own eyes

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

A bit better without those void pointers
//523 bytes void.h
int i;
#define STDMAIN main(int argc,char**argv){;
#define STDEND ;return 0;};
#define cs4p const int*
#define sort(array,function) qsort(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 sortp(array,function) sort(array,function);printints(array);
#include <stdio.h>
#include <stdlib.h>
cmpn(cs4p num1,cs4p num2){return *num1-*num2;}
cmpr(cs4p num1,cs4p num2){return *num2-*num1;}
//main.c 71 bytes
STDMAIN;int arr[]={6,5,8,1,10,4};sortp(arr,cmpn);sortp(arr,cmpr);STDEND

Name: Anonymous 2011-12-08 8:47

(defmacro once-only ((&rest names) &body body)
  (let ((gensyms (loop for n in names collect (gensym))))
    `(let (,@(loop for g in gensyms collect `(,g (gensym))))
      `(let (,,@(loop for g in gensyms for n in names collect ``(,,g ,,n)))
        ,(let (,@(loop for n in names for g in gensyms collect `(,n ,g)))
           ,@body)))))


Used in other macros to make sure arguments are only evaluated once. For example:

(defmacro m1 (x)
  `(+ ,x ,x))


(m1 (f)) expands to (+ (f) (f)).

(defmacro m2 (x)
  (once-only (x)
    `(+ ,x ,x)))


(m2 (f)) expands to something equivalent to (let ((y (f))) (+ y y)).

Name: Anonymous 2011-12-08 8:52

>>35
//removed bloated strings identifiers
//411 bytes void.h
int i;
#define STDMAIN main(int argc,char**argv){;
#define STDEND ;return 0;};
#define cs4p const int*
#define R return
#define s(a,f) qsort(a,sizeof(a)/sizeof(a[0]),sizeof(a[0]),f)
#define pi(a) ;for(i=0;i<(sizeof(a)/sizeof(a[0]));i++){printf("%d ",a[i]);};puts("");
#define sp(a,f) s(a,f);pi(a);
#include <stdio.h>
#include <stdlib.h>
cn(cs4p n1,cs4p n2){R *n1-*n2;}
cr(cs4p n1,cs4p n2){R *n2-*n1;}
//main.c 55 bytes
STDMAIN;int a[]={6,5,8,1,10,4};sp(a,cn);sp(a,cr);STDEND

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

>>36
Why you would need such a cludge to protect yourself from evaluating arguments?
Can you explain it in C terms?

Name: Anonymous 2011-12-08 8:57

Ok, I want you to implement a special sorting algorithm. in this algorithm you will implement a list with floating point numbers and integers. return a list that floating point at the beginning and sorted, after that sorted odd numbers and finally sorted even numbers. oh and append "hello world" to end of the list

(setq l '(6 5 2.0 9 0.0 2 1 4.5 8))
(append (sort (remove-if #'integerp l) #'<) (sort (remove-if  #'evenp (remove-if #'floatp l)) #'<) (sort (remove-if  #'oddp (remove-if #'floatp l)) #'<) "Hello World")

Name: Anonymous 2011-12-08 8:57

>>39
and output list is
(0.0 2.0 4.5 1 5 9 2 6 8 . "Hello World")

Name: Anonymous 2011-12-08 8:59

>>38
#define square(x) ((x) * (x))

square(rand() % 10) expands to ((rand() % 10) * (rand() % 10)). The macro is for when you only want the argument to be evaluated once, and then you use the returned value in the body of the macro.

Name: Anonymous 2011-12-08 9:01

Add syntax to C using the preprocessor.

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

>>41
if you want the rand() function to be evaluated once and this used for such cases, you easily use a function
inline int square(int x){int y=x; return y*y;}

Name: Anonymous 2011-12-08 9:08

Hey FV, what's your job?

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

>>44
I'm a free artist

Name: Anonymous 2011-12-08 9:09

>>45
And what "a free artist" does for living?

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

for ints:
square(int x){return x*x;}
for floats:
fsquare(float x){return x*x}
for doubles:
dsquare(double x){return x*x}

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

>>46
Anything he likes.

Name: Anonymous 2011-12-08 9:13

>>48
And how do earn money? You parents?

Name: Anonymous 2011-12-08 9:14

>>46
wastes welfare

Name: Anonymous 2011-12-08 9:16

I don't have a job
Just say it, bro

Name: Anonymous 2011-12-08 9:18

>>45
read: free autist

Name: Anonymous 2011-12-08 9:19

>>52
Should autists really be allowed to roam free?

Name: Anonymous 2011-12-08 9:21

>>53
As long as they don't invent any programming languages they are relatively harmless.

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

>>39
>list with floating point numbers and integers
Why are you storing the array of floats and ints at the same place?

Name: Anonymous 2011-12-08 9:32

>>55
to irk your static typed shit,
duh.
inb4 void*

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

>>56
I would just use 2 arrays and sort them separetely, with most effective sort speciazlied for the specific type.
using a mixed type array(actually an array of pointers for each element, incredibly bloated compared to int array)
make any comparison
1.first check the type of element
2.convert to common comparator type
3.compare and return result in common type
vs
1.compare two elements

Name: Anonymous 2011-12-08 9:59

>>57
Thats just an excuse. You can't write such code in C.

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

Name: Anonymous 2011-12-08 10:09

>>59
#define STDMAIN main(int argc,char**argv){;
why the fuck. why is function macro define srsly wtf.
SexuallyTransmittedDiseaseMAIN

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

>>60
STanDardMAIN
STanDardEND(Program)

Name: Anonymous 2011-12-08 10:17

>>61
I know what it's supposed to mean.
I'm just asking why the fuck would you define every function as a macro.

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

>>62
To make reusable code. I could stick those macro in void.h and use them for years.

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

>>62
consider writing 1000 C files, each could be started with
int main(int argc,char**argv){;
or
STDMAIN
which one would be easier?

Name: Anonymous 2011-12-08 10:19

>>59
so you are still arguing that C can do anything LISP does in an elegant way? I can't see an array of floats, ints in your code. it does not create a sorted array, just prints a string. and lisp code is like in two lines yet your (insufficent) C version is huge
also
(*a>*b)- (*a<*b)
lol

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

to make 1000 empty C files with same exact line #include <void.h> is left as exercise to the reader.

Name: Anonymous 2011-12-08 10:21

>>64
The one where I don't use C I use scheme because I'm not programming for an 8-bit embedded microcontroller.

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

Name: Anonymous 2011-12-08 10:25

>>68
why simply it is not *a-*b

Name: Anonymous 2011-12-08 10:27

>>63
I could stick those macro in void.h
Why did I even ask -_-
stick your dick in void.h get STD

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

>>69
doubles don't return 0, they return double 0.0

Name: Anonymous 2011-12-08 10:29

Your macros expands wrong half the time you know it right? for example

if(test)printints(array);
will expand like
if(test);for(i=0;i<(sizeof(array)/sizeof(array[0]));i++){printf("%d ",array[i]);};puts("");

do you really know C?

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

the type of return of *a-*b is double, and qsort expects the return of function to be integer.

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

>>72
I don't use such style:
if(test){printints(array); }

Name: Anonymous 2011-12-08 10:33

>>71
qsort is not stable, why do you even care equality?

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

If you expect to use short function syntax, write inline versions.
These are designed to avoid typing ;;; each time.

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

>>75
Its a comparator function which follow the standard qsort return type
1 first >second
0 equals
-1 second>first

Name: Anonymous 2011-12-08 10:36

>>74
it does not mean it is correct.

any way, I am done with this bullshit. enjoy your life

Name: Anonymous 2011-12-08 10:39

>>77
And standard qsort comparator function takes const void *.

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

>>78
I don't write inline version unless i need the return value from the macro.
printints(array) does not return a value, so it can be written as ;printints(array); to avoid typing extra ;; like
printints(array) puts("STD END MAIN");

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

>>79
 void* is the the universal type you can cast anything to it.

Name: Anonymous 2011-12-08 10:44

>>81
Yes but you are casting
int ( * comparator ) ( const void *, const void * )
to
int ( * comparator ) ( float *, float * )
which is not standard

Name: Anonymous 2011-12-08 10:45

>>82
whoops, reversed

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

>>82
I don't want any Haskell type restrictions in my C.

Name: Anonymous 2011-12-08 11:40

>>43
It was just an example. Sometimes you need to use a macro instead of a function, but you want the arguments (at least some of them) to only be evaluated once.

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

>>85
The function is textually identical to a macro call and can be used inline identically to a macro.

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

here are all variants of such calls:
int i;
#define STDMAIN main(int argc,char**argv){;
#define STDEND ;return 0;};
#define square_inline(x) ((x)=(x)*(x)) //evaluates X three times
#define square(x) ((x)*(x))  //evaluates X two times
inline int square_func(int x){return x*x;} //evaluates X one time
//pick any you like
STDMAIN;
int x=2;
printf(" %d",x);
square_inline(x);
printf(" %d",x);
x=square_func(x);
printf(" %d",x);
x=square(x);
printf(" %d",x);
STDEND

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

and a bonus void function
void square_via_pointer(int* x){*x*=*x;}

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

int i;
#define STDMAIN main(int argc,char**argv){;
#define STDEND ;return 0;};
#define square_inline(x) ((x)=(x)*(x))
#define square(x) ((x)*(x))
inline int square_func(int x){return x*x;}
void square_via_pointer(int* x){*x*=*x;}
STDMAIN;
int x=2;
printf(" %d",x);
square_inline(x);
printf(" %d",x);
x=square_func(x);
printf(" %d",x);
x=square(x);
printf(" %d",x);
square_via_pointer(&x);
printf(" %d",x);
STDEND

Name: Anonymous 2011-12-08 12:36

So, will anyone write an equivalent C macro for >>39
, or LISP wins?

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

>>90
if you can compare "hello world" to "0.0" you have problems

Name: Anonymous 2011-12-08 13:05

>>91
"hello world"
"0.0"
If you can't compare two strings, your language has problems.

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

>>91
Not that, 0.0 as double, which is 5th position
and "Hello World" as string at end.
Your macro can be used to compare 0.0 to "Hello World"
since i lack any Lisp interpreters, can you tell me what happens when you sort your "array" after the "hello world" is added?

Name: 2011-12-08 13:21

>remove-if #'integerp
and he claims that using a separate array is different
Typical LITHP retard

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

>>94
Its functionally different, he checks the value type(which is stored by LISP) so the array is constructed in-place.
Its incredibly inefficient, but "elegant". Still he didn't answer what happen when you sort the entire array with doubles ,ints, and "Hello world"

Name: Anonymous 2011-12-08 13:24

>>93
You don't even need an interpreter for that, since the only function attached to "Hello world" is append, and it's obvious what does it do (if not, see http://www.gnu.org/software/emacs/emacs-lisp-intro/html_node/append.html). How were you going to compete with LISP without knowing it?

Name: Anonymous 2011-12-08 13:26

1. lambda can't be done without heap allocation and some kind of non-trivial memory model. See
http://en.wikipedia.org/wiki/Funarg_problem
http://www.paulgraham.com/accgen.html
so stop posting your preprocessor garbage


2. but that has nothing to do with macros. Here's an idea: add monads to C. https://github.com/richhickey/clojure-contrib/blob/78ee9b3e64c5ac6082fb223fc79292175e8e4f0c/src/main/clojure/clojure/contrib/monads.clj#L51

Even just picking a single Monad for C would be hard, to say the least for generalizing the design pattern. Take Maybe for instance. Write a macro that makes it so that if any assignment in a block resolves to NULL, the whole block immediately returns NULL (and the other statements are not even evaluated.)

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

>>96
Can you describe what happens after append, can you sort the list or not?

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

>>97
If i want to juggle lambdas and compare double to strings, i'd rather use JavaScript.

Name: Anonymous 2011-12-08 13:33

>>98
I can't, but how is it related to the code snippet from >>39?

>>99
Mah boi, you probably want to re-read your OP post.

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

document.write([6, 5,2.0, 9, 0.0, 2, 1, 4.5, 8].sort(function(a,b)a-b)+" Hello World")

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