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

Incrementing i

Name: Anonymous 2009-03-16 8:40

i++; versus i+=1; versus i=i+1;

Discuss.

Name: Anonymous 2009-03-16 8:56

++i;

Name: Anonymous 2009-03-16 9:00

++i for EXTREME PERFORMANCE

Name: FrozenVoid 2009-03-16 9:02

i += sizeof "";

Name: Anonymous 2009-03-16 9:42

#define inc(x) 1+inc(x-1);

Name: Anonymous 2009-03-16 9:49

Anyone who uses i=i+1 deserves a fate worse than a fate worse than death. i++ FTW

Name: Anonymous 2009-03-16 10:01

i -=- 1;

Name: Anonymous 2009-03-16 10:09

i=i+1 only makes sense if i is either infinity or negative infinity.

Name: Anonymous 2009-03-16 10:22

>>8
EXPERT MATHEMATICIAN

Name: Anonymous 2009-03-16 10:33

vinc=new Function("return ++arguments[0]")

Name: Anonymous 2009-03-16 11:22

function incrementation_numeric(){
 if(isNaN(arguments[0]))
{
 return 'Not a number'
}else{
 var bnum=new Number(arguments[0]+1)
  if(isNaN(bnum))
 {
   return 'Out of range'
 }else{
   return bnum
  }
 }
}

Name: Anonymous 2009-03-16 11:36

Mutable state considered harmful.

Name: Anonymous 2009-03-16 11:38

let i' = succ i

Name: Anonymous 2009-03-16 11:50

Pardon my mistakes, my C has gotten a little rusty.

for(char *c := NULL; i>0; --i){
   int j;
   if (c) j := strlen(c); else j := 1;
   realloc(c, ++j);
   c[j-2] := ' '; c[j-1] := '\0';
}
i := strlen(c); free(c);

Name: Anonymous 2009-03-16 12:06

>>2
>>3
Thread should've ended here. This is clearly the best solution, which will likely result in just one machine instructions, while all other variations need compiler optimizations turned on to produce good code.

Name: Anonymous 2009-03-16 12:43

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>>15 does not understand /prog/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkm+gSQACgkQyfzi67YGTm/sUwCgpdoa9XiAng0QKcQpaDxBZ+XE
KLkAn16d/ylkMzIDZHN2BzU01PrXj5Ig
=0Abq
-----END PGP SIGNATURE-----

Name: Anonymous 2009-03-16 12:47

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>>16 is DQN

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)

iEYEARECAAYFAkm+gnAACgkQaCyy2qDbuDc0ygCfRaEZies8HRu/FtUwvxyIGokq
W2kAnim3SE4UK5T+/Y7o4hg8d4rn4Sjq
=u+mQ
-----END PGP SIGNATURE-----

Name: Anonymous 2009-03-16 12:50

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


We need a /prog/ keyserver.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkm+gvQACgkQds2F8BCEg8zMkQCdHM1gS8MzdSinxHf75y5tCKQX
DAsAoKPKPAV5xYS54/FeiXHWWNHLqFEh
=Dd6k
-----END PGP SIGNATURE-----

Name: Anonymous 2009-03-16 12:51

>>16
GPG crap
you wouldn't happen to know a guy by the name Donahoo would you?

Name: Anonymous 2009-03-16 13:36

>>16
>>18
Your GPG is ancient!

Name: Anonymous 2009-03-16 13:47

>>20
You mean stable. lol debian

Name: Anonymous 2009-03-16 14:01

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


>>16,18 might just be too dumb to use the correct gpg version.
Hint: gpg v2.x is called gpg2.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)

iEYEARECAAYFAkm+k70ACgkQdszBNMXUyxJrpwCgnMCVQX5xD1hOU1I28CZQcnr4
Ng4An0+5hO8G6sYnaw9jHRQUAv4WynCD
=ZDxf
-----END PGP SIGNATURE-----

Name: Anonymous 2009-03-16 14:34

I use state monad for that;

newtype State s a = State { runState :: (s -> (a,s)) }
 
instance Monad (State s) where
    return a        = State $ \s -> (a,s)
    (State x) >>= f = State $ \s -> let (v,s') = x s in runState (f v) s'

Name: Anonymous 2009-03-16 14:55

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


>>23
⑄ Please sign your posts! ⑄
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)

iEYEARECAAYFAkm+oG4ACgkQdszBNMXUyxJFwgCfb4yLHyO4HLQwe5JOOtj04IdD
A3IAoNcxF7/I8E4IXlmKgIOsFJ7JFFHE
=e6vw
-----END PGP SIGNATURE-----

Name: Anonymous 2009-03-16 14:56

GPGs Pretty Good

Name: Anonymous 2009-03-16 14:59

modifySTRef i (1+)

Name: Anonymous 2009-03-16 15:26

inc eax

Name: Anonymous 2009-03-16 22:50

(incf a)

Name: Anonymous 2009-03-17 2:39

>>27
Intel syntax considered harmful.

Name: Anonymous 2009-03-17 6:56

>>15

I don't think so, Dave.
i++;

Name: Anonymous 2009-03-17 9:02

++i > i++

Name: Anonymous 2009-03-17 9:07

>>29
Your considered harmful

Name: Anonymous 2009-03-17 9:09

>>31
undefined behavior, lrn2c

Name: Anonymous 2009-03-17 9:11

>>32
You're ALL considered unscientific and ultimately destructive.*



* The Sussman, 2008

Name: Anonymous 2009-03-17 9:13

>>33
how is it undefined? i guess i should have written
++i = i++;

confusing yes but well defined

Name: Anonymous 2009-03-17 9:23

>>35
idiot

Name: Anonymous 2009-03-17 9:30

>>36
[b]GENIUS[\b]

Name: Anonymous 2009-03-17 9:58

>>35
you modify i twice between sequence points.
you'd probably just end up getting i incremented one or two times, but in cases like that the compiler could rape your sister and still be complying with the standard.

Name: Anonymous 2009-03-17 11:39

>>38
the compiler could rape your sister
Fuck, I'm going to start using ++i = i++; in all programs I write just in case someone ever writes such a compiler.

Name: Anonymous 2009-03-17 12:32

>>39
You know, aniki, I'll rape your imouto for free if you want. No questions asked.

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