General FizzBuzz: Difference between revisions

m
→‎{{header|R}}: Syntax highlighting.
(Added solution for Action!)
m (→‎{{header|R}}: Syntax highlighting.)
Line 3,034:
===... solution===
The task asks that we assume 3 factors for the sake of simplicity. However, R makes the k factors case not much more complicated, so we will do that. The only major downside is that checking for malformed user input becomes so difficult that we will not bother.
<lang rrsplus>genFizzBuzz <- function(n, ...)
{
args <- list(...)
Line 3,055:
===Names solution===
If we deviate from the task's example of how to input parameters and instead use R's names facilities to make our (number, name) pairs, we get a much cleaner solution.
<lang rrsplus>namedGenFizzBuzz <- function(n, namedNums)
{
factors <- sort(namedNums)#Required by the task: We must go from least factor to greatest.
331

edits