You've just saved my day! Thanks a lot!
Best, Erich On Wed, 23 Sep 2015 10:38:07 -0400 Josh Grams <j...@qualdan.com> wrote: > On 2015-09-23 09:46AM, Erich Rast wrote: > >Someone on stackoverflow gave me a working implementation in Python 3 > > > >https://stackoverflow.com/questions/32694444/ > > > >but it uses advanced features and I have no clue how to translate > >this to Racket. > > Like this? > > #lang racket > > (define combinations ; from Rosetta code > (match-lambda** > [(_ 0) '(())] > [('() _) '()] > [((cons x xs) m) (append > (map (curry cons x) (combinations xs (- m 1))) > (combinations xs m))])) > > (define (preorders A) > (if (null? A) '(()) > (for*/fold ([result '()]) > ([k (range 1 (+ 1 (length A)))] > [B (combinations A k)] > [order (preorders (set-subtract A B))]) > (cons (cons B order) result)))) > -- 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.