Hi Matthias,

thanks for your reply ! :)


I am learning a lot especially from examples like you gave me!
:)

Cheers
Meino





Matthias Felleisen <matth...@ccs.neu.edu> [16-11-09 04:04]:
> 
> > On Nov 8, 2016, at 9:36 PM, meino.cra...@gmx.de wrote:
> > 
> > Hi,
> > 
> > From a list of items I want to select certain items. The selecting
> > criterion is the index (nth item).
> > 
> > From this list and from articles on the internet I think that indexing
> > a list and processing a list by index is not a good idea -- at least
> > it seems not to be very "lisp-y" or "racket-y"...
> > 
> > Other options I found:
> > * Convert the list into a vektor, select the indices and convert back.
> > * Do index based list processing none the less.
> > * ...?....
> > 
> > Unfortunately there is no other criterion to select the items.
> 
> Here is a way to use indexing into a list w/o incurring much of an overhead: 
> 
> #lang racket
> 
> (module+ test
>   (require rackunit))
> 
> ;; [forall X] [Listof X] N N -> [Listof X]
> 
> (module+ test
>   (check-equal? (pick-from-list-between '(a b c d) 1 2) '(b c)))
> 
> (define (pick-from-list-between lox lower upper)
>   (for/list ((x lox) (i (in-naturals)) #:when (<= lower i upper))
>     x))
> 
> 
> — Matthias, not like the rest of the country watching election results roll 
> in 

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