Re: New member
Don Mitchell <[email protected]> Fri, 15 Apr 2005 14:56:31 -0400
| Newsgroups | gmane.lisp.common-lisp |
|---|---|
| Message-ID | <[email protected]> |
It looks good. Some conventions that you should perhaps use
(not ()) s/b t that is, (if (= x iterator) t ...
() s/b nil
(= 0 foo) could more simply be (zerop foo) {the compiler should do the
right thing in the first case, but in the 2nd will definitely do it}
(if (= x iterator) t
(...)) could more simply be
(or (= x iterator) (...))
Similarly
(if (zerop foo) nil (prime-rfunc ...)) could more simply be
(and (not (zerop foo)) (prime-rfunc ...))
At 12:53 PM 4/15/2005, Richard Lewis wrote:
>Hello Common-lisp,
>
>I've just joined this list. I'm completely new to LISP and I'm not sure
>what the sort of tone to this list is; are newbie questions alright?
>
>I'll take a bit of a gamble and post my first ever LISP program for
>scrutiny, it takes a number as an argument and returns T if its prime
>and NIL if its not. (It doesn't do the non-algorithmic primes...)
>
>========================================
>(defun prime-rfunc (x iterator)
> (if (= x iterator) (not ())
> (if (= 0 (mod x iterator)) () (prime-rfunc x (1+
> iterator)))))
>
>(defun prime (x) (prime-rfunc x 2))
>
>(print (prime 1471))
>========================================
>
>Look forward to some comments!
>
>Cheers,
>Richard