Why do most implementations of FizzBuzz special case % 15? I haven't ever really understood this. Maybe it's just my math-y background, but it always seemed to me you should just check mod 3 and mod 5 without an else between them, concatenating Fizz and Buzz. Can anyone else comment on this? Most canonical FizzBuzz programs special case 15, and I don't get it.
Streem – a new programming language from Matz
41–50 of 199 posts
Re: Streem – a new programming language from Matz
#42As is you would have to put in filters to resplit input into lines and that is very messy for something that you will need/want to do very often.
For example if you wanted to parse by character it would be wonderful to be able to do the following:
STDIN | /./{|c|
# stuff
}
Even better would be if you took it a step further and offered something like regex pattern matching for the block input. e.g. STDIN | /\w+/{|word|
/house/ {
# when word is house
}
/car/ {
# when word is car
}
{
# default case
}
}Re: Streem – a new programming language from Matz
#43Why do most implementations of FizzBuzz special case % 15? I haven't ever really understood this. Maybe it's just my math-y background, but it always seemed to me you should just check mod 3 and mod 5 without an else between them, concatenating Fizz and Buzz. Can anyone else comment on this? Most canonical FizzBuzz programs special case 15, and I don't get it.
just because 15 HAPPENS to be a concatenation of the output of 3 and the output of 5 today doesn't mean it will be tomorrow. If I said "say Fizz for multiples of 3, Buzz for multiples of 5, and 'this is a silly coding problem' for multiples of 3 and 5 then you'd have to rewrite your code. Some of us know that clients ALWAYS change their minds, specs are rarely equivalent to the end result, and code against future cha…
Additionally, using %15 is not DRY. If the spec changes from saying "Fizz" on multiples of 3 to saying "Fizz" on multiples of 4, then you will have to also update 15->20. If you forget to do this, you have a bug.
The correct implementation is dependent on the problem's context, and such context is not available with the FizzBuzz problem.
Re: Streem – a new programming language from Matz
#44Not a fan of the closing braces.
Didn't Matz mention that he wasn't either, when explaining Rubys syntax? I'm a fan of indentation based blocks, so this seems like a step back for me :\
http://en.wikipedia.org/wiki/Off-side_rule#Off-side_rule_lan...
And I dont think declarative languages like SASS and Yaml count as they're not "programming languages". So I think that list is actually shorter. I don't see any of these languages outside of the 2 I mentioned as really "mainstream".
Re: Streem – a new programming language from Matz
#45Re: Streem – a new programming language from Matz
#46Reminds me a lot of Elixir's |> operator, which does the exact same thing. Nice! Curious how it'll turn out to compare with Elixir on other areas.
Could be cool, but Elxiir has the EVM under it, and that is some quality engineering. Ruby is good but kind of clownshoes.
Re: Streem – a new programming language from Matz
#47Re: Streem – a new programming language from Matz
#48Why do most implementations of FizzBuzz special case % 15? I haven't ever really understood this. Maybe it's just my math-y background, but it always seemed to me you should just check mod 3 and mod 5 without an else between them, concatenating Fizz and Buzz. Can anyone else comment on this? Most canonical FizzBuzz programs special case 15, and I don't get it.
just because 15 HAPPENS to be a concatenation of the output of 3 and the output of 5 today doesn't mean it will be tomorrow. If I said "say Fizz for multiples of 3, Buzz for multiples of 5, and 'this is a silly coding problem' for multiples of 3 and 5 then you'd have to rewrite your code. Some of us know that clients ALWAYS change their minds, specs are rarely equivalent to the end result, and code against future cha…
It's kind of a trivial test for that sort of recognition, but anything as small as FizzBuzz is going to be rather trivial.
Re: Streem – a new programming language from Matz
#49https://github.com/charlesmartin14/gnu_parallel
it is badly needed