[racket] Beginner question cons vs list vs ?

From: Leonard Cuff (lcuff2 at yahoo.com)
Date: Sun Apr 28 14:23:08 EDT 2013

I'm trying to teach myself scheme (racket) and decided to try writing
fizzbuzz.  My program mostly works, but instead of getting a single list, I
get a list with a dot before the last list item, which I assume means I've
got a 'cons' at the end rather than just one list. What am I doing wrong?
Any general comments on style or approach also welcome.

Thanks,

Leonard

#lang racket


(define (printer num)
  (cond((and (= 0 (remainder num 3)) (= 0 (remainder num 5))) 'fizzbuzz)
       ((= 0 (remainder num 3)) 'fizz)
       ((= 0 (remainder num 5)) 'buzz)
       (else num)))

(define (fizzbuzz limit)
  (define (helper current limit)
    (cond ((>= current limit) (printer limit))
          (else (cons (printer current)
                (helper (+ 1 current) limit)))))
  (helper 1 limit))

(fizzbuzz 10)

'(1 2 fizz 4 buzz fizz 7 8 fizz . buzz)
> 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130428/fb1239cc/attachment.html>

Posted on the users mailing list.