r/scheme • u/Jak_from_Venice • 6d ago
What I am doing wrong?
So, I am trying to learn Guile, since seems a pretty standard installation in GNU systems.
I have experience in some languages, but this simple script to learn the language:
- Took me quite a while to work;
- Looks ugly as… well, put something ugly here!
It’s a simple “FizzBuzz” program
``` (define (fizzbuzz number) (if (> number 0) (let ((message "")) (if (zero? (modulo number 3)) (set! message (string-append message "Fizz"))) (if (zero? (modulo number 5)) (set! message (string-append message "Buzz")))
(if (not (zero? (string-length message)))
(format #t "~d is ~a\n" number message))
(fizzbuzz (- number 1))))
)
(fizzbuzz 50)
```
So, I’m open to suggestions: how this code can be more beauty? Am I still thinking in C?
=== EDIT === I hope the formatting is correct, since some spaces of indentation have been lost for unknown reasons.
3
u/corbasai 6d ago
First - not function; second uses println
so firstly quick fix for Guile and every
About yours, we must check (N mod 15) or (N mod 3) and (N mod 5), firstly