Name:
F r o z e n V o i d !!mJCwdV5J0Xy2A212011-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 !!mJCwdV5J0Xy2A212011-12-08 10:40
>>79
void* is the the universal type you can cast anything to it.
Name:
Anonymous2011-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
>>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 !!mJCwdV5J0Xy2A212011-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 !!mJCwdV5J0Xy2A212011-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 !!mJCwdV5J0Xy2A212011-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 !!mJCwdV5J0Xy2A212011-12-08 12:17
So, will anyone write an equivalent C macro for >>39
, or LISP wins?
Name:
F r o z e n V o i d !!mJCwdV5J0Xy2A212011-12-08 12:59
>>90
if you can compare "hello world" to "0.0" you have problems
Name:
Anonymous2011-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 !!mJCwdV5J0Xy2A212011-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 !!mJCwdV5J0Xy2A212011-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"
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 !!mJCwdV5J0Xy2A212011-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 !!mJCwdV5J0Xy2A212011-12-08 13:29
>>97
If i want to juggle lambdas and compare double to strings, i'd rather use JavaScript.
Name:
Anonymous2011-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 !!mJCwdV5J0Xy2A212011-12-08 13:37
>>101
What is this supposed to write? "Javascript is better than LISP"?
Name:
F r o z e n V o i d !!mJCwdV5J0Xy2A212011-12-08 13:41
>>100
it shows that
A.provided C code does what LISP code does
B.LISP code is inefficient, checking each single value type, while constructing a new array for each sort.
C.LISP introduces a leaky abstraction of mixed array, while in reality you can't sort such mixed arrays(its undefined) even in LISP
D.the code in >>39 treats lists as sortable objects.
Name:
F r o z e n V o i d !!mJCwdV5J0Xy2A212011-12-08 13:45
>>102
its the only possible non-defective way to write such retarded code.
>>63 To make reusable code. I could stick those macro in void.h and use them for years.
You can just use them for years without redefining the names as well you know.
Name:
F r o z e n V o i d !!mJCwdV5J0Xy2A212011-12-08 13:56
>>105
I've written them from scratch just for the thread. Its not hard.
Name:
Anonymous2011-12-08 13:58
>>103
Wait, we do not talk here about efficiency. You have claimed you'll write an equivalent of the given LISP macro. Word equivalent includes, but not limited to doing what the LISP macro does. And we still can't see the equivalent C code yet.
Name:
Anonymous2011-12-08 14:01
>>106
It's not hard but it's pointless.
There is no good reason to make well known features into unknown features.
>>98
Stop asking if people can describe things to you. No one can describe things to you in a way that you will understand.
Name:
F r o z e n V o i d !!mJCwdV5J0Xy2A212011-12-08 14:04
if you want something that can sort list of mixed objects you have to define what the results would be.
What if list contains another list? whats its position? what if list is a string array? or complex number?
Can you say if List A is comparable to String C which comparable to double R?
Name:
F r o z e n V o i d !!mJCwdV5J0Xy2A212011-12-08 14:07
If you just stores objects in the list, why you object to storing each type in its own list?
DO you see how retarded is to mix objects and write functions specifically designed to fish out your specific object out of a LISP pile?
Name:
Anonymous2011-12-08 14:09
>>110
Please, point me at a LISP code which compares a list to a string, or a string to a double? Can't seem to find one ITT. As stated above, we do not want to abuse you with sorting lists of "mixed objects", but just numbers.
Name:
Anonymous2011-12-08 14:09
LITHP toilet midgets collecting integers from shitpiles.
I Lol'd, good one from FrozenTroll.
Name:
F r o z e n V o i d !!mJCwdV5J0Xy2A212011-12-08 14:18
>>117
If sort is a sorting function, it should
A.sort an array
B.provided array is a list of objects
If it does not the provided code is defective since no functionality is present.
If it does sort an "array" with strings and doubles the implementation is defective enough to allow such retarded code to be written.
And results of treating such "comparable objects" are bound to cause any sort of errors you cannot think from safe-from-type-casts language.
Name:
F r o z e n V o i d !!mJCwdV5J0Xy2A212011-12-08 14:20
I.e. you can't even use your sort function without writing yourself into
A.filtering code for each sort to fish out comparable types
B.undefined behavior for comparing incomparable types.
Name:
Anonymous2011-12-08 14:24
>>118
I have no idea what're you talking about. I just wanted to make sure we're talking about the same code snippet.