Hi John,

thank you for your reply ! :)

...no, not a homework...
I want to teach myself some racket and hope 'to get it' finally...
Since I am no native speaker I have the deficulty to search for
things, which names I dont know...

One example of my code is:

(define (trim-list lst)
  (if (empty? lst)
    lst
    (cons (string-trim (car lst)) (trim-list (cdr lst)))))


(define (walk-sublists lst)
  (if (empty? lst)
    lst
    (cons (trim-list (car lst)) (walk-sublists (cdr lst)))))

I want to avoid to call trim-list, if 'car lst' returns an empty list.
Instead 'car lst' sghould return the next non-empty list...

I will take a look in the reference manual for 'filter' and 'compose'.

Cheers
Meino





'John Clements' via Racket Users <[email protected]> [16-11-16 
18:26]:
> 
> > On Nov 15, 2016, at 19:52, [email protected] wrote:
> > 
> > Hi,
> > 
> > I have a list of sublists. Some of the sublists are empty.
> > The list should be processed recursevly and the resulting
> > list should no longer contain empty sublists.
> 
> Is this homework? 
> 
> if so: can you show your test cases?
> 
> if not: (filter (compose not null?) l).
> 
> 
> John Clements
> 
> > 
> > The code I have so far looks like:
> > 
> > (define (step-through-list lst)
> >    (if (empty? lst)
> >    lst
> >    (cons (process-sublist (car lst)) (step-through-list (cdr lst)))
> > 
> > ....but "car" would feed empty sublists to process-sublist as any other
> > sublist. How can I "silently" skip empty sublists and even get out of
> > the recursion without harm (if the last sublist is empty) without
> > switching to iteration?
> > Is there something like "car-not-empty" ? ;)
> > Or do I oversee the obvious here...? ;)))
> > 
> > Thank you vary much for any help in advance!
> > Cheers
> > Meino
> > 
> > 
> > -- 
> > 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 [email protected].
> > 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 [email protected].
> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to