Re: Walking a list
- From: Pascal Bourguignon <pjb@xxxxxxxxxxxxxxxxx>
- Date: Wed, 27 Jun 2007 21:40:59 +0200
Dan Bensen <randomgeek@xxxxxxxxxxxxxx> writes:
"Leslie P. Polzer" <leslie.polzer@xxxxxxx> wrote:
Suppose I want to keep track of the current element in a {singly,
doubly}-linked list (that might be circular) and at some point
cleanly advance it by one or more steps.
Pascal Bourguignon wrote:
Well, I hesitated to answer to the OP because he blatantly lied us,
since he mentionned singly and doubly linked lists, but the code he
showed cannot be list processing code in C
With all due respect, Pascal, that's the most ridiculous thing I've
heard this month. To use such strong language in response to a simple
technical issue, it's no wonder many people are put off by the Lisp
community. The logic of the question has nothing to do with the
presence or absence of a "previous" link.
Indeed, and my reasoning doesn't involve presence or absence of a
"previous" link, but the presence of absence of ANY link, vs the
pointer arithmetic used. When you follow links, you don't do pointer
arithmetic in C. When you do pointer arithmetic in C you aren't
dealing with lists, but with vectors (what they call "arrays").
In C I'd do something like that:
p++; /* might also be p += 5; */
What's the idiom for this stuff in Lisp? I'm sure there must be
some smug solution that, as usual, eludes me. Thanks, folks.
I still don't see the point of the OP's question...
Assuming "this stuff" refers to "p++" and "p += 5", the question
would seem to be how one implements that functionality in Lisp.
Perhaps you didn't like the "smug" descriptor? I don't think it was
meant seriously. I sort of like it :)
--
Dan
www.prairienet.org/~dsb/
--
__Pascal Bourguignon__ http://www.informatimago.com/
NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.
.
- Follow-Ups:
- Re: Walking a list
- From: Leslie P. Polzer
- Re: Walking a list
- From: Dan Bensen
- Re: Walking a list
- From: Andrew Reilly
- Re: Walking a list
- References:
- Walking a list
- From: Leslie P. Polzer
- Re: Walking a list
- From: Chris Russell
- Re: Walking a list
- From: Leslie P. Polzer
- Re: Walking a list
- From: Giorgos Keramidas
- Re: Walking a list
- From: Dan Bensen
- Re: Walking a list
- From: Pascal Bourguignon
- Re: Walking a list
- From: Dan Bensen
- Walking a list
- Prev by Date: Re: destructive modifications using iterate
- Next by Date: Re: Bootstrapping ANSI CL
- Previous by thread: Re: Walking a list
- Next by thread: Re: Walking a list
- Index(es):
Relevant Pages
|