help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple e-lisp question


From: Eric Lilja
Subject: Re: Simple e-lisp question
Date: Tue, 14 Apr 2009 22:54:01 +0200
User-agent: Thunderbird 2.0.0.21 (Windows/20090302)

Drew Adams wrote:

Lisp is English. If you can describe it clearly, you can code it.

If x has at least 2 elements, then 2nd, 1st, 3rd...
Else x

at least 2 = cdr
2nd        = cadr
1st        = car
3rd...     = cddr

(defun switch2 (x)
  (if (cdr x)
      (cons (cadr x) (cons (car x) (cddr x)))
    lst))

Hope this wasn't your only homework. ;-)

Thanks alot Mr Adams! And it wasn't even homework, just an old exercise I found.

- EL





reply via email to

[Prev in Thread] Current Thread [Next in Thread]