On Mon, Oct 31, 2016 at 10:53 PM, <meino.cra...@gmx.de> wrote: > Hi, > > I have a loooong list of something. And I have a recursive serach > function to crawl down the list and search for a previously determined > item. > When found, the search processes stops and returns that item of the > list. > > In a second step, I want to process the list starting with that > certain item til the end of the list. > > Is it possible to jump right into a list at a certain item of > the list and to start processing there? Could the search function > return a certain extra information so that another function could > pick up that item directly and start recursing from there? > """Distributed recursion""" somehow...? > > The tail of a non-empty list is simply a list, so, if I understand you correctly, what you want to do is very straightforward. The `member` (and `memq` / `memv` / `memf` ) functions are meant for exactly this sort of thing. In your first step, instead of returning just the member of the list you're interested in, you can return the sublist that starts with that item. For example, let's say you have a list of strings that looks like this:
(define xs '("one" "two" "three" "four" "five")) And you want to find "three." Then you can do: (member "three" xs) ... which returns: '("three" "four" "five") The first element of the result is the element you wanted, and the remainder of the list is everything after it. You'll want `memf` if you need to search by some arbitrary function. See the documentation for this group of functions. - Jon -- 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.