Jump to content

FizzBuzz: Difference between revisions

Added a solution and explanation for Rhovas
(→‎{{header|Vlang}}: Rename "Vlang" in "V (Vlang)")
(Added a solution and explanation for Rhovas)
Line 8,882:
/*stick a fork in it, we're all done. */</syntaxhighlight>
'''output''' &nbsp; is identical to the 1<sup>st</sup> REXX version. <br><br>
 
=={{header|Rhovas}}==
Standard FizzBuzz using a pattern matching approach:
* <code>range(1, 100, :incl)</code> creates an inclusion range
* <code>.for {</code> iterates through the range, with the current element being <code>val</code>
* Pattern matching on <code>[val.mod(3), val.mod(5)]</code> is used to check divisibility conditions
** <code>[0, 0]</code>, for instance, matches when <code>val</code>is divisible by both <code>3</code> and <code>5</code>
** <code>else</code> matches all other possibilities, in this case when <code>val</code> is not divisible by <code>3</code> or <code>5</code>
 
<syntaxhighlight lang="scala">
range(1, 100, :incl).for {
match ([val.mod(3), val.mod(5)]) {
[0, 0]: print("FizzBuzz");
[0, _]: print("Fizz");
[_, 0]: print("Buzz");
else: print(val);
}
};
</syntaxhighlight>
 
=={{header|Ring}}==
4

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.