On Tue, Nov 1, 2016 at 1:34 PM, John Clements <cleme...@brinckerhoff.org>
wrote:

>
> > On Nov 1, 2016, at 8:02 AM, David Storrs <david.sto...@gmail.com> wrote:
> >
> ...
> > > Is it possible to jump right into a list at a certain item of
> > > the list and to start processing there?
> >
> > Yes.  What you want is list-ref
> >
> > (define my-list '(a b c d e f g))
> >
> > (list-ref (list 'a 'b 'c) 0)
> > 'a
>
>
> Oog, no, don’t do that. The earlier solution, by returning the list (or,
> if you prefer, “a pointer to the list”), ensure that the entire (resumed)
> search takes time linear in the length of the list. But indexing into the
> list with ‘list-ref’ will require re-traversing the first part of the list,
> probably turning an O(n) operation into an O(n^2) operation.


> Right?
>

Yep.  I should perhaps have been more clear that what I was saying was "to
answer your immediate question: yes, list-ref is a thing, but in general
the solutions I am about to propose are better."



>
> John
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to