Hello ALUG,
I thought I'd try and learn LISP for fun!
I've found some good tutorials on the web but I can't seem to find a mailing list. I found common-lisp@ai.sri.com but I can't find archives for it and the description I read makes it sound like they may not like newbie questions. Does anyone know of any LISP lists that would be good for newbies?
And if anyone on ALUG has any experience with LISP:
I've been writing a 'hello world' program which consists of a function that returns T if the given parameter is prime or else it returns NIL; the only thing is, it doesn't work. It always returns NIL which I think its getting from the <then> clause of the second (if ) function. I think I may have misunderstood the way that LISP functions return their results: if the number is prime then it should return the (not ()) from the first (if ) function but it doesn't.
Heres the code in case anyone knows about LISP:
======================================== ; the recursive function: (defun prime-rfunc (x iterator) (print x) ; for debugging (print (1+ iterator)) ; for debugging (if (= x iterator) (not ()) (if (= 0 (mod x (1+ iterator))) () (prime-rfunc x (1+ iterator))) ) )
; because the recursive function takes a second, ; non-variable argument, prime is a wrapper function ; which just takes the intuitive first argument: (defun prime (x) (prime-func x 1))
; test it: (print (prime 7)) ========================================
Cheers, Richard
On Tue, 12 Apr 2005 15:27:53 +0100, "Richard Lewis" richardlewis@fastmail.co.uk said:
I've been writing a 'hello world' program which consists of a function that returns T if the given parameter is prime or else it returns NIL; the only thing is, it doesn't work.
Scrub that, I've just fixed it:
==================================== (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)) ====================================
R.
Richard wrote:
And if anyone on ALUG has any experience with LISP:
There's a group of schemers (scheme is a lisp, different to common lisp) who meet roughly monthly in London. I can send details when they announce the May meeting, if you want.
Apologies for not looking at the specific problem any time soon.
On Thu, 28 Apr 2005 20:25:17 +0100, "MJ Ray" mjr@dsl.pipex.com said:
Richard wrote:
And if anyone on ALUG has any experience with LISP:
There's a group of schemers (scheme is a lisp, different to common lisp) who meet roughly monthly in London. I can send details when they announce the May meeting, if you want.
Thanks for the tip. I've just found their website (sort of): http://lisp.meetup.com/13/
Apologies for not looking at the specific problem any time soon.
I worked out that little prime number function and have been fiddling with some other jobs in my spare time. I've just found Nyquist which looks like good fun! (http://cec.wustl.edu/~bjl1/nyquist-linux.html)
Cheers, Richard