[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

What's the coolest code you've seen?

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 23
Thread images: 2

File: 1458848688244.png (166KB, 2000x1000px) Image search: [Google]
1458848688244.png
166KB, 2000x1000px
?
>>
>>56332345
Quake source code
>>
MAKE EVERYTHING STATIC
>>
>>56332345
(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
>>
File: qtt.png (129KB, 314x278px) Image search: [Google]
qtt.png
129KB, 314x278px
>>56332572
>>
>>56332411
I am a Unity babby and I know this
>>
>>56332411
why
>>
>>56332572
What does it do?
>>
>>56334627
It shows off his autism.
>>
>>56332572

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.
>>
>>56332345
sudoku solver in 33 lines of clojure
https://gist.github.com/swannodette/3217582
>>
>>56332371
>>56335735
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;
}
>>
>>56332345
Quake's Engine's source code is pretty beautiful.
>>
>>56336751
>>56332371
Is there a C++ variant of it?
>>
This Malbolge
(=<_@^]nZH:FWD0w.dc1aqM-&8H)5hhC$dA.Q`<^Myxw7uts!~p/R@P,=<K(JIGGb"CYkA@?>fvQcO'`RQJn1Mj/hgff)vD'&A@]][}5GXED0fAd?+*<;'n+lkjh~%${zy~w={z\rqvutsrk1Rhmlkjiha`_d]#[`YX]VzZ<Rv9ONSRQJImMLK-IHAeE'=<;_?>=654X2Vw54-Q10/.-,l$H('&%|#"y?}_uzsrwvutm3Tpihmlkjc)gfHdcb[!_^]\[ZYXWVUTSRKPImGLEDIHAe(>C<`@">=<;:321U/.-210/.'K+$#('&%$#"y?}|{zyxq7Xnmrqj0nglkjihgf_%FbaZ~^]?UZYRvVUTSRQPONMLKJIHGF?c=BA@98=<;4X87w5432+*/(L&+*#"!E}|{"y?}_{zyxq7uWmrkponmlkjc)gfHdcb[!BX|V[ZYRvVUTSLKoO1GFEJIBfFEDC%A@?8\<;{3816543,P*/(',+$HG'~%$#zy?}|{]yxwp6tVrqj0nmlkMihg`&dcbD`_XW{[=YRQVOsSR4Jn1MFEiCBG@dDCB$@?>7[|498165.RQ10p.-,+*)('~D$dzyx>|uzyr8Yutmlqjih.Oe+ihgfedcba`_^]?UZYXWVUTSLpJOHMLKDhHG@?c&B;:9]~<5Y9876/4-Q+*).'&%I)i'&%|B"!~w={zyxwYutmrqj0{
>>
>>56336727
Isn't that what a union is for?
>>
>>56336819
Yes, but back then, it was undefined behaviour to use unions that way.
>>
>>56334627
It's CL's dotimes loop implemented in Scheme, complete with a return statement.

>>56335699
Yes, it is Scheme. Try it in Guile or Racket.
>>
>>56336778

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 <':'&&c>48)
?x=x1,y=y1,*(c>'3'&&c<':' ?&y1: &t)
+=(y2-y1)/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<=x2; x+=(x2-
x1)/q){a=b=c=0; while ( ++c&&(a=(t
=a)*a)<4&&(v=b*b)<4)a-=v-x ,b=y+b*2*t;
putchar("#@XMW*N&KPBQYKG$R" "STEEVxHOUV"
"CT()[]%JL={}eou?/\\|Ili+~<>_-^\"!;:`,. "[
c?c>>2:63]);}} while((c=getchar ())!='x');
return 0;/* Mandelbrot - S.Goodwin.2001*/}


(the formatting is probabyl gonna be fucked up)
>>
>>56337437
and in python
_                                      =   (
255,
lambda
V ,B,c
:c and Y(V*V+B,B, c
-1)if(abs(V)<6)else
( 2+c-4*abs(V)**-0.4)/i
) ;v, x=1500,1000;C=range(v*x
);import struct;P=struct.pack;M,\
j ='<QIIHHHH',open('M.bmp','wb').write
for X in j('BM'+P(M,v*x*3+26,26,12,v,x,1,24))or C:
i ,Y=_;j(P('BBB',*(lambda T:(T*80+T**9
*i-950*T **99,T*70-880*T**18+701*
T **9 ,T*i**(1-T**45*2)))(sum(
[ Y(0,(A%3/3.+X%v+(X/v+
A/3/3.-x/2)/1j)*2.5
/x -2.7,i)**2 for \
A in C
[:9]])
/9)
) )
>>
>>56332345

>prefixing class names with type initial
absolutely disgusting
Thread posts: 23
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.