## Brief codereview and freshman pep talk

You have problems, and we're glad to hear them. Explain the problem, what you have tried, and where you got stuck.
Feel free to share a little info on yourself and the course.
Forum rules
Please respect your teacher's guidelines. Homework is a learning tool. If we just post answers, we aren't actually helping. When you post questions, be sure to show what you have tried or what you don't understand.

### Brief codereview and freshman pep talk

Hi everyone! Not exactly a homework again, but fits here better.

I'm a C++ programmer and on my staycation I've decided to challenge myself and do a couple of Project Euler problems and to challenge myself even more I've decided that it is the perfect time for me to realize my long-held dream and learn some lisp at last! I've read several chapters of Land of Lisp, that's all my background here. So my first question is where I can discuss things I wrote preferable in realtime (e.g. IRC or telegram), is this forum alive anyway?

The problem itself (it is deep in an archive so now we can discuss it freely without spoilers):
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.

After a considerable amount of time I've came up with something like that
Code: Select all
`(defun sum-multiplies-by-3-or-5 (n)  (labels ((is-dividable-by (num divisor)                            (zerop (mod num divisor)))           (is-dividable-by-3-or-5 (num)                                   (or (is-dividable-by num 3)                                       (is-dividable-by num 5)))           (impl (cur sum)                 (cond ((= cur n) sum)                       ((is-dividable-by-3-or-5 cur) (impl (1+ cur) (+ sum cur)))                       ((impl (1+ cur) sum)))))    (impl 3 0)))`

So now I have a billion questions about how good this code is, e.g
* should I hide functions like is-dividable-by or make them global if they are generic enough?
* recursion is a more true way of doing that than a loop?
* is the pattern of doing a local function to use it recursively good?
* what is not so good in this code that you can see right away?

Thanks!
babysitter

Posts: 2
Joined: Thu Jan 17, 2019 3:45 am

### Re: Brief codereview and freshman pep talk

where I can discuss things I wrote preferable in realtime (e.g. IRC or telegram)

looks like I found a pretty cool Discord channel tho
babysitter

Posts: 2
Joined: Thu Jan 17, 2019 3:45 am