Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Code that may or may not pass muster

Name: Anonymous 2009-10-01 2:42

I know we've got some computer science students in here, and I know you've written some questionable code at 2:30 in the morning before your project is due. So post it here! Preferably one-liners. Here's mine. I'm interested to see what my prof thinks of it... opinions could differ.

printf("%.1f%c", *e, (0 == (e - matrix + 1) % size)?'\n':'\t');

Name: Anonymous 2009-10-01 2:48

printf
Problem found! printf will bottleneck your code, especially when dealing with matrixen'

Name: Anonymous 2009-10-01 3:08

>>2
Don't worry, anyone spending much time running this program must be looking to waste their time anyway.

Name: Anonymous 2009-10-01 3:41

printf("%.1f%c", *e, ((e - matrix + 1)%size)?'\t':'\n');

Better.

Name: Anonymous 2009-10-01 3:50

>>4
The zero is there so readers know I'm comparing for numerical value. And why didn't you get rid of the extra parens if you're into pointless minimalism?

Name: Anonymous 2009-10-01 4:03

>>5
The compiler takes no heed of extra parens and it will result in exactly the same compiled code. You're comparison on the other hand..

Name: Anonymous 2009-10-01 4:40

>>6
My are comparison will make use of an instruction like x86's JNE.

Name: Anonymous 2009-10-01 5:06

>>7
Several clock cycles slower than using JNZ.

Name: Anonymous 2009-10-01 5:23

>>7
Not everyone uses a toy processor architecture like x86

Name: Anonymous 2009-10-01 6:12

>>9
x86 doesn't has enough power for toys, they use ARM.

Name: Anonymous 2009-10-01 6:20

>>10
doesn't has
english isn't your first language

Name: Anonymous 2009-10-01 6:24

>>11
that's the kind of attitude hitler had

Name: Anonymous 2009-10-01 6:26

>>12
I am not an anti-semite

Name: Anonymous 2009-10-01 6:28

>>11
grammar nazis in MY /prog/???
are we getting raided by gaia or something?

Name: Anonymous 2009-10-01 6:38

>>14
Non-sense, gaia has much more culture and posts are at least 10 times bigger.

Name: Anonymous 2009-10-01 6:40

>>14
IHBT

Name: Anonymous 2009-10-01 7:24

>>14
You're not clever.

Name: Anonymous 2009-10-01 8:04

>>17
that hurts.
really.
D:

Name: Anonymous 2009-10-01 8:20

printf("%c", ********c);

That was pretty deep

Name: Anonymous 2009-10-01 8:33

one of my favorite beautiful pieces of c is this switch technique:


switch(foo) {
  case 1:
    s = "one";
    if(0)
  case 2:
    s = "two";
    if(0)
  case 3:
    s = "three";
    blah(s);
    break
}

Name: Anonymous 2009-10-01 8:35

>>20
|⌒彡
|冫、)
|` /

Name: Anonymous 2009-10-01 8:36

>>21
lol hy

Name: Anonymous 2009-10-01 8:37

>>21
is that the boy twin from rugrats?

Name: Anonymous 2009-10-01 8:38

>>20
what the hell?
i assume that if(0) functions the same as break;.
GENIUS!

Name: Anonymous 2009-10-01 8:41

>>24
no, it means it skips the first line of the next case, but then continues. this allows a common section for the 3 cases, but also specific code for each

Name: Anonymous 2009-10-01 8:46

>>25
mind == blown
amazing

Name: Anonymous 2009-10-01 8:51

>>25
thats gay

Name: Anonymous 2009-10-01 8:52

>>27
your gay

Name: Anonymous 2009-10-01 9:08

>>20
haha
try doing that in haskell. oh wait. U CANT BCUZ HASKELL SUCKS

Name: Anonymous 2009-10-01 9:30

>>20
OH GOD IT'S SO BEAUTIFUL!

Name: Anonymous 2009-10-01 10:04

>>20
sweet bro

Name: Anonymous 2009-10-01 10:14

>>29
I know, right? Haskell doesn't even have goto. What kind of toy language doesn't have goto?

Name: Anonymous 2009-10-01 10:33

>>32
A language... with call/cc.

Name: Anonymous 2009-10-01 10:39

>>33
call-with-current-continuation-because-yo-momma-said-so

Name: Anonymous 2009-10-01 12:09

ENTERPRISE QUALITY

Name: Anonymous 2009-10-01 12:35

i wrote this today.
i don't think it's actually very bad, but i felt kinda bad about it because i've always been told that gotos are bad mojo.

while((c = getchar()) != EOF){
   int i;
   for(i = 0; i < str1_len; ++i){
      if(c == str1[i]){
         goto next_outer;
      }
   }
   putchar(c);
   next_outer:;
}


in case you're wondering, what it does is prettymuch the same as tr -d

Name: Anonymous 2009-10-01 13:12

>>32
Inb4 someone writes a Goto Monad

Name: Anonymous 2009-10-01 13:26

>>36
c <- getChar
let str' = str ++ filter (not . flip elem str) [c]

Name: Anonymous 2009-10-01 13:30

>>37
main = runBASIC' $ do
    10 PRINT "Already done."
    20 GOTO 10

Name: Anonymous 2009-10-01 13:37

>>39
This is why I hate Haskellers >:-|

Name: Anonymous 2009-10-01 15:22

>>37
Well, there already is the Continuation monad.

Name: Anonymous 2009-10-01 20:14

>>26
I am amazed by blah(s)

Name: Anonymous 2009-10-02 4:29

>>42
blah(s) is an [b]EXPERT FUNCTION NAME[/]b]

Name: Anonymous 2009-10-02 12:19

>>43
#<COMPILED-PROCEDURE:BLAH>

Name: Anonymous 2009-10-02 12:21

#<FUNCTION BLAH>

Name: Anonymous 2009-10-02 12:31

>>> blah
<function blah at 0xb801b72c>

Name: Anonymous 2009-10-02 12:36


blah
#<procedure:blah>

Name: Anonymous 2009-10-02 14:39

draw_text(text+ending,font,(10-scroll_text,15+font_height+(i*font_height)+((ani/10.0)*font_height)),color)

sup

Name: Anonymous 2009-10-02 20:40

HWND* dicks = make_print_window(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 400, 400);

Name: Anonymous 2009-10-03 6:00


(define math:cos (get-ffi-obj "cos" (ffi-lib "libc") (_fun _double -> _double)))


Chicken Scheme users: don't even dare pussy out and use the c library.

Name: Anonymous 2009-10-03 17:28

>>49
Ludicrous. I can tell you right now that any API like that would not pass muster. Nobody would publish it.

Name: Anonymous 2009-10-03 20:26

>>51
take a look at msdn some day

Name: Anonymous 2009-10-03 20:36

>>52
You'd better get your Internet sarcasm detector checked.

Name: Anonymous 2009-10-03 20:37

>>53
You forgot to use [sarcasm] tags

Name: Anonymous 2009-10-03 20:41

>>52
How does someone this dumb know how to use the internet?

Name: Anonymous 2009-10-03 20:54

>>55
say that to my face fucker and not online and see what happens

Name: Anonymous 2009-10-03 22:06

>>56
I would require your address and what hours you would be available to show me what would happen when I told you that to your face and not online.

Name: Anonymous 2009-10-08 16:19

PHP:

$set = function ($bool) { $var = $bool; };
$var = $set(true);
if ($var == true) { echo 'var is true'; };

Name: Anonymous 2010-11-25 21:01

Name: Anonymous 2010-12-17 1:30

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Name: Anonymous 2011-02-02 22:48


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