Discussion of Common Lisp
-
joeish80829
- Posts: 153
- Joined: Tue Sep 03, 2013 5:32 am
Post
by joeish80829 » Fri May 09, 2014 12:28 am
;I got this whittled down as much as I can...for some reason I cant call (aref arg i) in a cond statement twice in a row. I do have to verify it is a vector 2 different ways, before I run (aref arg 0) and (aref arg i) as below...How can I do this?...I'm getting deleting unreachable code error.
Code: Select all
(defun vector-test (&optional arg i)
(cond ((vectorp arg) (aref arg 0))
((and (vectorp arg) i) (aref arg i))))
-
porky11
- Posts: 25
- Joined: Fri May 02, 2014 6:46 am
Post
by porky11 » Fri May 09, 2014 6:39 am
If the second condition is true, the first condition also is true, so the first will be executed.
you could change the lines or use multiple
ifs like this:
Code: Select all
(defun vector-test (&optional arg i)
(if (vectorp arg)
(if i
(aref arg 0)
(aref arg i))))