[racket] shortest paths, resource allocation/scheduling

From: Jos Koot (jos.koot at telefonica.net)
Date: Mon Dec 5 16:24:26 EST 2011

If there is a less-than predicate for the elements of the list, the list can
be sorted and things may be speeded up, I think.

-----Original Message-----
From: users-bounces at racket-lang.org [mailto:users-bounces at racket-lang.org]
On Behalf Of Eli Barzilay
Sent: lunes, 05 de diciembre de 2011 21:17
To: Ryan Culpepper
Cc: users at racket-lang.org
Subject: Re: [racket] shortest paths, resource allocation/scheduling

Three hours ago, Ryan Culpepper wrote:
> Here's the basic idea:
> ;; subsets-of-size : nat list -> (listof list)
> (define (subsets-of-size n l)
>    (cond [(zero? n) (list null)]
>          [else
>           (for*/list ([ne-list (pair-fold-right cons null l)]
>                       [subsetN-1
>                        (in-list (subsets-of-size (sub1 n)
>                                                  (cdr ne-list)))])
>             (cons (car ne-list) subsetN-1))]))
> This has bad complexity, I believe, although I haven't calculated
> it. If you add in memoization, though, you should get good
> (optimal?) complexity and optimal tail-sharing.

There was a long discussion about this on c.l.scheme a number of years
ago, with a bunch of people trying to write optimized code.  The
bottom line was that a simpe memoization was as fast as the best
hand-optimized versions.  See the results here:
http://scheme.barzilay.org/subsets/ with a link to the sources that I

(But note that it's really ancient (around 10 years, I think), so the
code looks bad, and the timings are likely to look different now.)

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!
  For list-related administrative tasks:

Posted on the users mailing list.