Re: Walking a list



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.
.



Relevant Pages

  • Re: merits of Lisp vs Python
    ... Pascal Bourguignon wrote: ... First note that this NTH function is designed only to work on function calls: ... so CALL-ARGUMENTS-LIMIT is effectively the maximum length of the lists ...
    (comp.lang.lisp)
  • Re: merits of Lisp vs Python
    ... Pascal Bourguignon wrote: ... First note that this NTH function is designed only to work on function calls: ... so CALL-ARGUMENTS-LIMIT is effectively the maximum length of the lists ... Real time: 20.745884 sec. ...
    (comp.lang.lisp)
  • Re: When to use apply
    ... > Pascal Bourguignon wrote: ... >> But then, it'd expand to: ... >> and this wouldn't work because + expects numbers not lists. ... Prev by Date: ...
    (comp.lang.lisp)
  • Re: When to use apply
    ... Pascal Bourguignon wrote: ... > But then, it'd expand to: ... > and this wouldn't work because + expects numbers not lists. ... Prev by Date: ...
    (comp.lang.lisp)
  • Re: mapcar irritation
    ... Pascal Bourguignon writes: ... We're not discussing lists, we're discussing ... > multiple vaules. ... OK, I misread that. ...
    (comp.lang.lisp)