[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: if/else execution in elisp
From: |
Ehud Karni |
Subject: |
Re: if/else execution in elisp |
Date: |
Sun, 20 Oct 2002 23:35:28 +0200 |
On Sun, 20 Oct 2002 15:36:03 -0400 (EDT), ken <ken@cleveland.lug.net> wrote:
>
> (defun testo-func ()
> (setq
> zlist '(2 65535 3)
> firsto (car zlist)
> segundo (car (cdr zlist))
> thirdo (cdr (cdr zlist)))
This should be:
thirdo (car (cdr (cdr zlist))))
>
> (if (> segundo 44671)
> (setq firsto (+ 2 firsto) segundo (- 44672 segundo))
The correct expression is: segundo (- segundo 44672))
> (setq firsto (+ 1 firsto) segundo (+ 20864 segundo))
> )
> (list firsto segundo thirdo)
> )
Now it works as you expect.
I suggest the use of the `nth' built-in function (check its help)
for getting the nth element of a list, instead of `(car (cdr ...'
Ehud.
--
Ehud Karni Tel: +972-3-7966-561 /"\
Mivtach - Simon Fax: +972-3-7966-667 \ / ASCII Ribbon Campaign
Insurance agencies (USA) voice mail and X Against HTML Mail
http://www.mvs.co.il FAX: 1-815-5509341 / \
mailto:ehud@unix.mvs.co.il Better Safe Than Sorry