Thanks a lot to all,
This mail-chain has produced at least three ways of doing the same thing and all of them are different and elegant.
Great going guys... let us start some thing interesting like a project developed by us. I really like to join some project which has GPL but would like to that with in our group. What do you suggest?
A fair warning from my side that I am a new lisper so learning a lot from you all.
Thanks to all again,
Samik
P.S. If any one of you have some time for my blog please visit it and post your suggestion there:
----- Original Message ----
From: pramod shinde <prmdshinde@...>
To: bangalore-lisp@yahoogroups.com
Sent: Tuesday, 18 September, 2007 9:22:41 AM
Subject: Re: [bangalore-lisp] About reverse function
Pramod K.Shinde
Building a website is a piece of cake.
Yahoo! Small Business gives you all the tools to get online.
From: pramod shinde <prmdshinde@...>
To: bangalore-lisp@yahoogroups.com
Sent: Tuesday, 18 September, 2007 9:22:41 AM
Subject: Re: [bangalore-lisp] About reverse function
Thanks samik,
i m able to do the reverse function:
(defun rev (x)
(if (endp x)
nil
(append (rev (cdr x)) (list (car x)))))
> rev '(a b c a d)
(d a c b a)
(d a c b a)
----- Original Message ----
From: samik chakraborty <samik_126@yahoo. co.in>
To: bangalore-lisp@ yahoogroups. com
Sent: Sunday, September 16, 2007 10:14:53 PM
Subject: Re: [bangalore-lisp] About reverse function
Did you know? You can CHAT without downloading messenger. Click here
From: samik chakraborty <samik_126@yahoo. co.in>
To: bangalore-lisp@ yahoogroups. com
Sent: Sunday, September 16, 2007 10:14:53 PM
Subject: Re: [bangalore-lisp] About reverse function
Hi Pramod,
Sorry to spell your name incorrect last time. The following code uses a recursive call to do a reverse of a list only problem is the tr variable it needs to be set to ‘() each time after a call to this reverse function. I must be missing something stupid here if you can rectify it, will be great.
CL-USER> (setf tr '())
CL-USER> (defun rev(lst)
(setf tr (list* (car lst) tr))
(if (not (eq (cdr lst) nil))
(rev (cdr lst))
(return-from rev tr)))
CL-USER> (rev (list 1 2 3 4 5))
(5 4 3 2 1)
As always, very best
Samik
----- Original Message ----
From: pramod shinde <prmdshinde@yahoo. com>
To: bangalore-lisp@ yahoogroups. com
Sent: Monday, 17 September, 2007 2:50:08 AM
Subject: [bangalore-lisp] About reverse function
Yahoo! oneSearch: Finally, mobile search that gives answers, not web links.
From: pramod shinde <prmdshinde@yahoo. com>
To: bangalore-lisp@ yahoogroups. com
Sent: Monday, 17 September, 2007 2:50:08 AM
Subject: [bangalore-lisp] About reverse function
Hi all ,
Can anybody write the recursive function LISP function that will reverse elements of the list(please don't use built-in reverse function).?
I have tried the answer with car,cdar,last, lastbut .But I am not able to come at exact answer.
Can anybody write the recursive function LISP function that will reverse elements of the list(please don't use built-in reverse function).?
I have tried the answer with car,cdar,last, lastbut .But I am not able to come at exact answer.
Thanks for your any suggestion.
Regards,
Pramod K.Shinde Regards,
Yahoo! oneSearch: Finally, mobile search that gives answers, not web links.
Did you know? You can CHAT without downloading messenger. Click here
Building a website is a piece of cake.
Yahoo! Small Business gives you all the tools to get online.
Try the revolutionary next-gen Yahoo! Mail. Click here.