The most beautiful loop structure

Posted by s on April 27, 2008, 2:56 p.m.

int a,v,g=500;int[] p=new int[g+1];

void setup(){

a=1;while(a++<sqrt(g)){if(p[a]==0){v=a*a;while(v<=g){p[v]=1;v+=a;}}}

a=0;while(a++<g){print(a+" "+(p[a]==0)+"\n");}}

I don't know why everyone likes for(;;), though do{}until has the obvious uses. And I know that most people don't seem to like for, because they seem to be overloading it with that awful thing we call syntax (Glares are Ruby and Python, PERL is too old school to change for(;;))

Anyways, me and Ruby got in a fight. I just didn't believe in wrapping up if{} in fancy feathers. I guess I'm too old school to see why {} is ugly

And that's the other thing. They say ; gives better form. But all it does for me is make me merge lines (glares at how ugly PERL can get). So ya, forcing a statement per line makes people write cleaner code and we don't have ; everywhere. Which, I'll add, doesn't mean the parser can't fix

add(1,

2)

That being said, I don't like the comma. Ya, Lisp showed me the way. add(1 2) would do a language some good. Too bad people like doing 1 + 2 instead of 1+2(I was kind of liking the stack based languages, they don't get enough attention. Yay for 1 2 + a * 4 / 10 -(Ya, you can guess why they don't have many languages like that. Dang ALGOL junkies))

[url=http://www.urbandictionary.com/define.php?term=Asperger's+Syndrome]Sad when the light of truth can only be found on joke sites like this (Tinted with the regular bull, of course)[/url]

Comments

PY 16 years, 8 months ago

add(1 2) would make sense, actually, free up the comma for real uses.

s 16 years, 8 months ago

Ya, could make it a good noop operator