DEV Community

loading...

Discussion on: Fizz Buzz in Every Language

Collapse
nepeckman profile image
nepeckman

I raise you the compile time calculated fizzbuzz in Nim ;)

proc fizzbuzz(): seq[string] =
  result = @[]
  for i in 1..100:
    result.add(
      if i mod 15 == 0: "FizzBuzz"
      elif i mod 5 == 0: "Buzz"
      elif i mod 3 == 0: "Fizz"
      else: $i
    )

const compileTimeValue = fizzbuzz()

echo compileTimeValue
Collapse
renegadecoder94 profile image
Jeremy Grifski Author

Interested in adding this to the collection? 😁

Collapse
slurpsmadrips profile image
Isabella Muerte

C++20 isn't available yet, but we're a bit closer to this approach. :)