all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Array or Vector?
@ 2008-09-10 15:11 Nordlöw
  2008-09-10 15:57 ` Drew Adams
  0 siblings, 1 reply; 2+ messages in thread
From: Nordlöw @ 2008-09-10 15:11 UTC (permalink / raw)
  To: help-gnu-emacs

When, in Emacs Lisp, is it preferrable to use a list over a vector and
vice versa?

My guess is
- vector: for fast static sequences
- list: for dynamically growing sequences

/Nordlöw


^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: Array or Vector?
  2008-09-10 15:11 Array or Vector? Nordlöw
@ 2008-09-10 15:57 ` Drew Adams
  0 siblings, 0 replies; 2+ messages in thread
From: Drew Adams @ 2008-09-10 15:57 UTC (permalink / raw)
  To: 'Nordlöw', help-gnu-emacs

> When, in Emacs Lisp, is it preferrable to use a list over a vector and
> vice versa?
> 
> My guess is
> - vector: for fast static sequences
> - list: for dynamically growing sequences

Yes (growing, shrinking, ...). And array, not necessarily vector.

See Elisp manual, node Sequences Arrays Vectors:

  An "array" is a single primitive object that has a slot for each of
  its elements.  All the elements are accessible in constant time, but
  the length of an existing array cannot be changed.  Strings, vectors,
  char-tables and bool-vectors are the four types of arrays.

  A list is a sequence of elements, but it is not a single primitive
  object; it is made of cons cells, one cell per element.  Finding the
  Nth element requires looking through N cons cells, so elements farther
  from the beginning of the list take longer to access.  But it is
  possible to add elements to the list, or remove elements.

The Elisp manual is your friend.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-09-10 15:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-10 15:11 Array or Vector? Nordlöw
2008-09-10 15:57 ` Drew Adams

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.