all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: kai.grossjohann@gmx.net (Kai Großjohann)
Subject: Re: LISP: Very Very Basic Question.
Date: Wed, 09 Apr 2003 15:59:49 +0200	[thread overview]
Message-ID: <84u1d793fu.fsf@lucy.is.informatik.uni-duisburg.de> (raw)
In-Reply-To: mailman.4322.1049863665.21513.help-gnu-emacs@gnu.org

Gurucharan <gurucharan.murudeshwar@wipro.com> writes:

>        Can anyone explain the way in which the LISP "list"
>
> is implemented internally ?

The basic data structure is a cons cell.  It is a pair consisting of
a car and a cdr.  The car and the cdr can be numbers or strings etc,
or pointers to cons cells.

For example, (1 . 2) is a cons cell where the car is 1 and the cdr is
2.

You can build binary trees from cons cells:

( (1 . 2) . (3 . 4) )

This corresponds to the following tree:

    *
   / \
  *   *
 / \ / \
 1 2 3 4

There is a special value nil which means "empty", other languages use
the term "null".

A list is a degenerated binary tree, where the cars contain the list
elements, and the cdr points to the rest of the list.  And nil means
the empty list.  So (1 . nil) is a one-element list, and (1 . (2 .
nil)) is a two-element list, and (1 . (2 . (3 . nil))) is a
three-element list.  The three-element list as a tree:

    *
   / \
  1   *
     / \
    2   *
       / \
      3   nil

-- 
A preposition is not a good thing to end a sentence with.

  parent reply	other threads:[~2003-04-09 13:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-07 20:27 List Seperator Artist
2003-04-07 20:52 ` Johan Bockgård
2003-04-09  4:22   ` Artist
2003-04-09  4:53     ` LISP: Very Very Basic Question Gurucharan
     [not found]     ` <mailman.4322.1049863665.21513.help-gnu-emacs@gnu.org>
2003-04-09 13:50       ` lawrence mitchell
2003-04-09 13:59       ` Kai Großjohann [this message]
2003-04-09 15:04     ` List Seperator Johan Bockgård

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=84u1d793fu.fsf@lucy.is.informatik.uni-duisburg.de \
    --to=kai.grossjohann@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.