• Re: A style question

    From B. Pym@Nobody447095@here-nor-there.org to comp.lang.lisp,comp.lang.scheme on Fri Jul 25 09:33:02 2025
    From Newsgroup: comp.lang.lisp

    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.
    --
    [T]he problem is that lispniks are as cultish as any other devout group and basically fall down frothing at the mouth if they see [heterodoxy].
    --- Kenny Tilton
    The good news is, it's not Lisp that sucks, but Common Lisp. --- Paul Graham --- Synchronet 3.21a-Linux NewsLink 1.2
  • From B. Pym@Nobody447095@here-nor-there.org to comp.lang.lisp,comp.lang.scheme on Sat Jul 26 03:36:35 2025
    From Newsgroup: comp.lang.lisp

    B. Pym wrote:

    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.

    (use srfi-42) ;; do-ec looping macro.

    (do-ec (: i 1 101)
    (let1 printed #f
    (do-plist ((n s) '(3 fizz 5 buzz 7 bang))
    (when (= 0 (mod i n))
    (write s) (set! printed #t)))
    (unless printed (write i))
    (print)))
    --
    [T]he problem is that lispniks are as cultish as any other devout group and basically fall down frothing at the mouth if they see [heterodoxy].
    --- Kenny Tilton
    The good news is, it's not Lisp that sucks, but Common Lisp. --- Paul Graham --- Synchronet 3.21a-Linux NewsLink 1.2