[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Indexing a vector
From: |
Juanma Barranquero |
Subject: |
Re: Indexing a vector |
Date: |
Wed, 10 Sep 2008 17:57:50 +0200 |
On Wed, Sep 10, 2008 at 16:53, Nordlöw <per.nordlow@gmail.com> wrote:
> How do index an element in a vector?
(aref [a b c d] 2) => c
> nth() works only for lists.
Yes, `nth' is a list operation.
> Why on earth isn't such a basic operator compatible with both lists
> and vectors (sequences)?
Because it is a list operation. For the generic sequence operator, try `elt':
(elt '(a b c d) 2) => c
(elt [a b c d] 2) => c
(elt "abcd" 2) => 99
Juanma