Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Subsets of a list
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
George Caswell  
View profile  
 More options Jan 11 2002, 5:37 pm
Newsgroups: comp.lang.scheme
From: George Caswell <tetsu...@maine.rr.com>
Date: Fri, 11 Jan 2002 22:34:43 GMT
Local: Fri, Jan 11 2002 5:34 pm
Subject: Re: Subsets of a list
On 11 Jan 2002, John David Stone wrote:

> George Caswell <tetsu...@maine.rr.com> writes:

> >    Anyway, my implementation, "subs" uses up a lot of heap space compared to,
> > say, "combos" posted by John Stone, and incurs more garbage collection, but
> > still comes out faster:

> > (define (expand xs sets)
> >     (if (or (null? xs) (null? sets))
> >         ()
> >       (cons
> >           (apply append (map (lambda (set) (map (lambda (s) (cons (car xs)
> > s)) set)) (cdr sets)))
> >           (expand (cdr xs) (cdr sets)))
> > ))

> > (define (subs xs n)
> >     (cond ((eq? 0 n) ())
> >         (else
> >           (do ((i 1 (+ i 1))
> >                (acc (map (lambda (x) (list (list x))) xs) (expand xs acc)))
> >               ((= i n) (apply append acc))))))

>         I used SUBS to find all the ten-element subsets of a twenty-element
> set, in the same environment (Chez Scheme 6.1, Linux, 700MHz Pentium III)
> where SUBSETS took 460 ms and COMBOS took 250 ms for the same task.  SUBS
> took 990 ms.

   Strange...  I'd attribute it to garbage collection time - though in any
case, on the tests I ran subs was only marginally faster than combos anyway.
Oh, well, back to the drawing board.  :)

---GEC
Projects page: http://home.maine.rr.com/tetsujin/
(M-x depeche-mode)
"Must...  Finish...  Zaku..."


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.