Sinisterly
FizzBuzz in 10 programming languages - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Coding (https://sinister.li/Forum-Coding--71)
+--- Thread: FizzBuzz in 10 programming languages (/Thread-FizzBuzz-in-10-programming-languages)

Pages: 1 2


RE: FizzBuzz in 10 programming languages - Deque - 07-08-2013

(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/codeconv-138413.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.


RE: FizzBuzz in 10 programming languages - Deque - 07-08-2013

(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/codeconv-138413.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.


RE: FizzBuzz in 10 programming languages - noize - 07-08-2013

(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?


RE: FizzBuzz in 10 programming languages - noize - 07-08-2013

(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?


RE: FizzBuzz in 10 programming languages - noize - 07-08-2013

(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?


RE: FizzBuzz in 10 programming languages - Deque - 07-08-2013

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.


RE: FizzBuzz in 10 programming languages - Deque - 07-08-2013

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.


RE: FizzBuzz in 10 programming languages - Deque - 07-08-2013

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.