Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 27 |
Nodes: | 6 (0 / 6) |
Uptime: | 41:17:22 |
Calls: | 631 |
Calls today: | 2 |
Files: | 1,187 |
D/L today: |
24 files (29,813K bytes) |
Messages: | 174,725 |
Another friend of mine commenting on the same FizzBuzz thread supplied
the following Python code. It certainly is concise:
for i in xrange(1,101):
print(str(i), "Fizz", "Buzz", "FizzBuzz")[(i%3==0)|(i%5==0)<<1]
Another friend of mine commenting on the same FizzBuzz thread supplied
the following Python code. It certainly is concise:
for i in xrange(1,101):
print(str(i), "Fizz", "Buzz", "FizzBuzz")[(i%3==0)|(i%5==0)<<1]
Gauche Scheme
(use srfi-42) ;; do-ec looping macro.
(define (z? n) (if (= 0 n) 1 0))
(define % mod)
(do-ec (: i 1 101)
(print (~ `(,i Fizz Buzz FizzBuzz)
(+ (z? (% i 3)) (* (z? (% i 5)) 2)))))
After removing unnecessary blanks, it's shorter than the
Python version.