What's the coolest code you've seen?

?

Other urls found in this thread:

gist.github.com/swannodette/3217582
twitter.com/SFWRedditGifs

Quake source code

MAKE EVERYTHING STATIC

(define-syntax dotimes
(lambda (x)
(syntax-case x ()
((_ (var count) body ...)
(with-syntax ((return (datum->syntax x 'return)))
#'(call/cc (lambda (return)
((lambda (f)
(f 0 f))
(lambda (var f)
(if (< var count)
(begin body
...
(f (+ 1 var) f))))))))))))

(dotimes (i 10) (when (= i 5)
(return i)))

Macro magic

...

I am a Unity babby and I know this

why

What does it do?

It shows off his autism.

Is this scheme?

I tried to run it but my compiler didn't know the "define-syntax" keyword..

Fast inverse square root is pretty cool.

sudoku solver in 33 lines of clojure
gist.github.com/swannodette/3217582

this

float Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;

x2 = number * 0.5F;
y = number;
i = * ( long * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed

return y;
}

Quake's Engine's source code is pretty beautiful.

Is there a C++ variant of it?

This Malbolge
(=C

Isn't that what a union is for?

Yes, but back then, it was undefined behaviour to use unions that way.

It's CL's dotimes loop implemented in Scheme, complete with a return statement.

Yes, it is Scheme. Try it in Guile or Racket.

Can't risk losing my mobo

mandelbrot code in C formatted as a mandelbrot set

int main(int argc, char* argv[]){ unsigned
char c='r';double x1,y,y1,t=0,q=78,r=22,x,
x2,y2,a,b,v;do{(c=='r')?(y2=-(y1=-1.6),x1=
-2.0f,x2=0.8):(c=='?')? c=0, printf("%f\
,%f:%f,%f",x1,y1,x2,y2):(c 48)
?x=x1,y=y1,*(c>'3'&&c'6'&&c< ':'?&y1
:&t)+=(y2-y1)/3, *((c == '8'
||c+3=='8'||c+3 +3== '8'?&x1
:&t))+=(x2-x1 )/ 3,*((c
=='9'||c+3== '9'||c
+6=='9' ?&x1: &t)
)+=2*(x2-x1) /3,x2=
x1+(x2-x)/3, y2 =y1+(
y2-y)/3:(c=0);for(y= y2;y>=
y1&&c;c=1,y-=(y2-y1)/r, putchar
('\n')) for(x=x1;x

and in python
_ = (
255,
lambda
V ,B,c
:c and Y(V*V+B,B, c
-1)if(abs(V)

>prefixing class names with type initial
absolutely disgusting