General FizzBuzz: Difference between revisions
Content deleted Content added
→{{header|Lua}}: Changed to reflect changes in the original (Python) version. |
→{{header|Lua}}: Removed default values, added output. |
||
Line 1,166: | Line 1,166: | ||
'''One of the few solutions which do not use expensive modulo ''(think about the CPU!)''.''' |
'''One of the few solutions which do not use expensive modulo ''(think about the CPU!)''.''' |
||
{{trans|Python}} |
{{trans|Python}} |
||
<lang Lua>local |
<lang Lua>local function fizzbuzz(n, mods) |
||
local mods_def = { |
|||
⚫ | |||
⚫ | |||
⚫ | |||
} |
|||
⚫ | |||
n = n or n_def |
|||
mods = #mods ~= 0 and mods or mods_def |
|||
local res = {} |
local res = {} |
||
Line 1,212: | Line 1,202: | ||
end |
end |
||
</lang> |
</lang> |
||
{{out}} |
|||
<pre> |
|||
> mods = { |
|||
⚫ | |||
⚫ | |||
⚫ | |||
>> } |
|||
⚫ | |||
1 |
|||
broccoli |
|||
cheese sauce |
|||
broccoli |
|||
5 |
|||
cheese broccoli sauce |
|||
7 |
|||
broccoli </pre> |
|||
=={{header|Nim}}== |
=={{header|Nim}}== |