Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 26 |
Nodes: | 6 (0 / 6) |
Uptime: | 59:24:07 |
Calls: | 633 |
Calls today: | 1 |
Files: | 1,188 |
D/L today: |
32 files (20,076K bytes) |
Messages: | 180,583 |
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.