Earlier quoted context omitted.
It's not any shorter. The extra check as to whether or not to print the line break cancels out the mod 15 check. In my opinion, it's cleaner to have three conditionals of the same type than two checking mods and a third checking the OR of the first two. Of course, it can be actually shorter with a goto.
Whether you print the number, Fizz, Buzz or FizzBuzz you are going output a line break, so I'm not sure what you would be checking for. Output \n unconditionally.
Streem – a new programming language from Matz
61–70 of 199 posts
Re: Streem – a new programming language from Matz
#62I'm not sure everyone is familiar enough with Ruby to know who Matz is.
Re: Streem – a new programming language from Matz
#63Re: Streem – a new programming language from Matz
#64Earlier quoted context omitted.
Whether you print the number, Fizz, Buzz or FizzBuzz you are going output a line break, so I'm not sure what you would be checking for. Output \n unconditionally.
then you'd get \n \n fizz\n \n buzz\n rather than fizz\n buzz\n
1\n2\nFizz\n4\nBuzz\n...\nFizzBuzz\n
If you did not print anything for some cases, you're right that it could not be unconditional (though it could still be done at the end with a flag).
Re: Streem – a new programming language from Matz
#65Re: Streem – a new programming language from Matz
#66Earlier quoted context omitted.
then you'd get \n \n fizz\n \n buzz\n rather than fizz\n buzz\n
The canonical FizzBuzz wants 1\n2\nFizz\n4\nBuzz\n...\nFizzBuzz\n If you did not print anything for some cases, you're right that it could not be unconditional (though it could still be done at the end with a flag).
Re: Streem – a new programming language from Matz
#67Reminds 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.
I've never heard of Elixir, but I always assumed that the |> originated in F#. Ocaml has it pretty much standard, too, although you can define it in one line in Ocaml: let (|>) x f = f x
The following code computes the sum of squares of all positive numbers of a list:
list |> Enum.filter(&(&1 > 0)) |> Enum.map(&(&1 * &1)) |> Enum.reduce(0, &(&1 + &2))
Re: Streem – a new programming language from Matz
#68I'm not really a programming language expert, but it seems to me that having an implementation being the spec wouldn't be a good idea. If the Streem implementation has a bug, then the bug becomes the authoritative behavior. Any platform specific quirks would also make it difficult to have defined behavior.
So, while I'll agree that there are issues that come from the implementation being the spec of a language in general, I would say we are well earlier than the point at which we can identify that as a problem with Streem.
Re: Streem – a new programming language from Matz
#69I am glad that someone is working on a new stream processing language, it is a very interesting paradigm. However I hope that they provide some very robust tools for controlling input splitting. As I have spent too much time fighting with awk and wishing it was more flexible(it is frustrating always having exactly two levels of splitting with only matchers on the first and only inverse splitting on the second). As is…
Reference: https://www.gnu.org/software/sed/manual/sed.html#Examples
Sorry, I couldn't miss that one. :) Really, check the example. Sed is most powerful tool and can do astonishing work.
Re: Streem – a new programming language from Matz
#70[deleted]