Hi David,

thanks for your...:) DOCUMENTATION PROJECT :).....!!!
Whow!
Now I have a lot to read! 

Cheers
Meino


David Storrs <david.sto...@gmail.com> [16-11-01 18:47]:
> Hi Meino,
> 
> Good news!  There are built-ins that will do almost all of this for you:
> 
> 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.
> 
> Check the following pages:
> https://docs.racket-lang.org/reference/pairs.html  (cf 'member' and 'memf')
> https://docs.racket-lang.org/guide/for.html   (short intro on 'for')
> https://docs.racket-lang.org/reference/for.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for%29%29
> (full documentation of all versions of 'for')
> 
> >
> > 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?
> 
> Yes.  What you want is list-ref
> <https://docs.racket-lang.org/reference/pairs.html?q=list-ref#%28def._%28%28quote._%7E23%7E25kernel%29._list-ref%29%29>
> 
> (define my-list '(a b c d e f g))
> 
> (list-ref
> <https://docs.racket-lang.org/reference/pairs.html?q=list-ref#%28def._%28%28quote._%7E23%7E25kernel%29._list-ref%29%29>
>  (list
> <https://docs.racket-lang.org/reference/pairs.html?q=list-ref#%28def._%28%28quote._%7E23%7E25kernel%29._list%29%29>
>  'a 'b 'c) 0)
> 
> 'a
> 
> 
> >  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...?
> 
> Yes.  There's various ways, but the simplest would be:
> 
> (define my-list '(a b c d e f g))
> (define search (lambda (x) (equal? x 'd)))
> (define further-processing (lambda (lst) ( ... do something here ...)))
> 
> (memf search my-list)  ;;   =>  returns '(d e f g)
> 
> 
> ;;   Find the interesting element, save the list from that point on for
> future use
> (define interesting-part-of-list
>     (memf search my-list))
> 
> ;;   Or, alternatively, find the interesting element, then send it and the
> rest of the list directly to 'further-processing'
> (further-processing
>     (memf search my-list))
> 
> 
> Side note:  The following two ways of defining a function are equivalent:
> 
> (define foo (lambda (x) 7))
> (define (foo x) 7)
> 
> 
> Hope this helps.
> 
> Dave
> 
> -- 
> 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.

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