From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: florian Newsgroups: gmane.emacs.help Subject: Manipulating lists somewhere in the middle (index-based) Date: Fri, 12 Jun 2009 13:16:46 -0700 (PDT) Organization: http://groups.google.com Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1244839307 11969 80.91.229.12 (12 Jun 2009 20:41:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 12 Jun 2009 20:41:47 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jun 12 22:41:45 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MFDZE-0006qm-L0 for geh-help-gnu-emacs@m.gmane.org; Fri, 12 Jun 2009 22:41:40 +0200 Original-Received: from localhost ([127.0.0.1]:48315 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MFDZD-0003eG-Nm for geh-help-gnu-emacs@m.gmane.org; Fri, 12 Jun 2009 16:41:39 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!c18g2000prh.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 45 Original-NNTP-Posting-Host: 92.73.165.181 Original-X-Trace: posting.google.com 1244837806 3726 127.0.0.1 (12 Jun 2009 20:16:46 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Fri, 12 Jun 2009 20:16:46 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: c18g2000prh.googlegroups.com; posting-host=92.73.165.181; posting-account=D6LMWQoAAAA9mPFBi-XXlCxVbyI2qOo- User-Agent: G2/1.0 X-HTTP-UserAgent: Opera/9.63 (X11; Linux i686; U; en) Presto/2.1.1,gzip(gfe),gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:169994 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:65212 Archived-At: I know there was a similar discussion yesterday (see http://groups.google.de/group/gnu.emacs.help/browse_thread/thread/2fc2d1ea2229f3bc), but that involved examining elements. I am actually just wondering whether I reinvented the wheel in writing two (non-destructive) functions: (drop-nth 2 '(1 2 3 4 5)) => (1 2 4 5) (squeeze-in-at 2 "three" '(1 2 4 5)) => (1 2 "three" 4 5) My function definitions are probably not particularly interesting (if anybody thinks they are, just let me know - they both simply work by building a new list and returning it), but what I am wondering about is this: when looking at the linked-paired-boxes notation the Elisp manual uses to explain lists: --- --- --- --- --- --- | | |--> | | |--> | | |--> nil --- --- --- --- --- --- | | | | | | --> fir --> oak --> maple [slightly modified] it is actually very tempting to suspect there must be a way to directly make the pointer from the cdr of "fir" point to the car of the "maple" element and making the car of "oak" point to nil instead, thus dropping the element from the list and getting (fir maple) as the result. Or, the other way round, it looks as if there could be a way to make the pointer of the "oak" element point to a new cons cell, which has "birch" as its car, and whose cdr we have point to the car of the "maple" element, so as to get the list (fir oak birch maple). Is there in fact some way to mess with these pointers, or is that a purely didactic concept? Thanks for any input, it is really just curiosity about Elisp! Florian