Login Register






FizzBuzz in 10 programming languages filter_list
Author
Message
RE: FizzBuzz in 10 programming languages #11
(07-07-2013, 09:59 PM)noize Wrote: I'll change the class names (only one llitter's got to be uppercase, right?), though, it works this way too, is there any actual difference or is it just convention?

Convention only. http://www.oracle.com/technetwork/java/c...38413.html

To be exact, this is what the conventions say:

Quote:Class names should be nouns, in mixed case with the first letter of each internal word capitalized

Quote:The main function in C does *not* need a return statement: it's a void function. For the variable, yes, you're right.

Wrong. You even declared it as int main. You have to return the status code, 0 for success, another integer if an error happened.
Some compilers will allow you to have a void main, but that's against the standard of the language and you should avoid it at all costs.

Quote:Why is it odd to start a loop at 1? :huh:

Because most programmers do:
for i = 0; i < 100; i++
But actually I got it wrong here, as the FizzBuzz test states it should go from 1 to 100.

Quote:I'm not good with Python, you know, may I get a brief reason for what you're argueing?

range() creates a list that is saved in memory. xrange() is more like a generator. The numbers are only created when needed.

Quote:Edit: you know Prolog too?

Yes, I took two AI courses and there we used Prolog. It's a relatively easy language in the sense that it uses one algorithm for resolution and once you understood it, there isn't much else to know. (One of my professors wrote an interpreter for prolog in Haskell within a single lecture.)
But you need a very good understanding of mathematical logic. It is a logic programming language.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: FizzBuzz in 10 programming languages #12
(07-07-2013, 09:59 PM)noize Wrote: I'll change the class names (only one llitter's got to be uppercase, right?), though, it works this way too, is there any actual difference or is it just convention?

Convention only. http://www.oracle.com/technetwork/java/c...38413.html

To be exact, this is what the conventions say:

Quote:Class names should be nouns, in mixed case with the first letter of each internal word capitalized

Quote:The main function in C does *not* need a return statement: it's a void function. For the variable, yes, you're right.

Wrong. You even declared it as int main. You have to return the status code, 0 for success, another integer if an error happened.
Some compilers will allow you to have a void main, but that's against the standard of the language and you should avoid it at all costs.

Quote:Why is it odd to start a loop at 1? :huh:

Because most programmers do:
for i = 0; i < 100; i++
But actually I got it wrong here, as the FizzBuzz test states it should go from 1 to 100.

Quote:I'm not good with Python, you know, may I get a brief reason for what you're argueing?

range() creates a list that is saved in memory. xrange() is more like a generator. The numbers are only created when needed.

Quote:Edit: you know Prolog too?

Yes, I took two AI courses and there we used Prolog. It's a relatively easy language in the sense that it uses one algorithm for resolution and once you understood it, there isn't much else to know. (One of my professors wrote an interpreter for prolog in Haskell within a single lecture.)
But you need a very good understanding of mathematical logic. It is a logic programming language.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: FizzBuzz in 10 programming languages #13
(07-08-2013, 07:57 AM)Deque Wrote: Wrong. You even declared it as int main. You have to return the status code, 0 for success, another integer if an error happened.
Some compilers will allow you to have a void main, but that's against the standard of the language and you should avoid it at all costs.

Holy fucking crap, I really thought I had declared it as void, but I just noticed it is an int, well, I'm just about to change this.

Quote:
Quote:Why is it odd to start a loop at 1? :huh:

Because most programmers do:
for i = 0; i < 100; i++
But actually I got it wrong here, as the FizzBuzz test states it should go from 1 to 100.

Yes, exactly, that's why I did it: because the range for the FizzBuzz was 1..100.

Quote:range() creates a list that is saved in memory. xrange() is more like a generator. The numbers are only created when needed.

For the output it's just the same? range goes from the starting number to the number before the ending number, xrange is just the same, isn't it? I'll just change this one too.

I'd love to see some Prolog tutorial, is there any chance I will?
My Bitcoin address: 1AtxVsSSG2Z8JfjNy9KNFDUN6haeKr7LiP
Give me money by visiting www.google.com here: http://coin-ads.com/6Ol83U

If you want a Bitcoin URL shortener/advertiser, please, use this referral: http://coin-ads.com/register.php?refid=noize

Reply

RE: FizzBuzz in 10 programming languages #14
(07-08-2013, 07:57 AM)Deque Wrote: Wrong. You even declared it as int main. You have to return the status code, 0 for success, another integer if an error happened.
Some compilers will allow you to have a void main, but that's against the standard of the language and you should avoid it at all costs.

Holy fucking crap, I really thought I had declared it as void, but I just noticed it is an int, well, I'm just about to change this.

Quote:
Quote:Why is it odd to start a loop at 1? :huh:

Because most programmers do:
for i = 0; i < 100; i++
But actually I got it wrong here, as the FizzBuzz test states it should go from 1 to 100.

Yes, exactly, that's why I did it: because the range for the FizzBuzz was 1..100.

Quote:range() creates a list that is saved in memory. xrange() is more like a generator. The numbers are only created when needed.

For the output it's just the same? range goes from the starting number to the number before the ending number, xrange is just the same, isn't it? I'll just change this one too.

I'd love to see some Prolog tutorial, is there any chance I will?
My Bitcoin address: 1AtxVsSSG2Z8JfjNy9KNFDUN6haeKr7LiP
Give me money by visiting www.google.com here: http://coin-ads.com/6Ol83U

If you want a Bitcoin URL shortener/advertiser, please, use this referral: http://coin-ads.com/register.php?refid=noize

Reply

RE: FizzBuzz in 10 programming languages #15
(07-08-2013, 07:57 AM)Deque Wrote: Wrong. You even declared it as int main. You have to return the status code, 0 for success, another integer if an error happened.
Some compilers will allow you to have a void main, but that's against the standard of the language and you should avoid it at all costs.

Holy fucking crap, I really thought I had declared it as void, but I just noticed it is an int, well, I'm just about to change this.

Quote:
Quote:Why is it odd to start a loop at 1? :huh:

Because most programmers do:
for i = 0; i < 100; i++
But actually I got it wrong here, as the FizzBuzz test states it should go from 1 to 100.

Yes, exactly, that's why I did it: because the range for the FizzBuzz was 1..100.

Quote:range() creates a list that is saved in memory. xrange() is more like a generator. The numbers are only created when needed.

For the output it's just the same? range goes from the starting number to the number before the ending number, xrange is just the same, isn't it? I'll just change this one too.

I'd love to see some Prolog tutorial, is there any chance I will?
My Bitcoin address: 1AtxVsSSG2Z8JfjNy9KNFDUN6haeKr7LiP
Give me money by visiting www.google.com here: http://coin-ads.com/6Ol83U

If you want a Bitcoin URL shortener/advertiser, please, use this referral: http://coin-ads.com/register.php?refid=noize

Reply

RE: FizzBuzz in 10 programming languages #16
I won't promise a Prolog tutorial, but I thought about doing one, yes.

xrange won't give you a list. But the usage for the for loop is the same.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: FizzBuzz in 10 programming languages #17
I won't promise a Prolog tutorial, but I thought about doing one, yes.

xrange won't give you a list. But the usage for the for loop is the same.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: FizzBuzz in 10 programming languages #18
I won't promise a Prolog tutorial, but I thought about doing one, yes.

xrange won't give you a list. But the usage for the for loop is the same.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply