Perl tuning/speed question: all subsets of a set of length k -- keeping the inital order

[Posted and a courtesy copy mailed.]

Quote:

> I got some problem, and I wonder how close to the speed of C I can get

> with the following problem. I appreciate all your input a lot.

I have a solution, not tuned for speed, and certainly not compared to

the speed of C.

Quote:

> k is an integer between 1 and 25.

> (e.g. keep the original order of the words)

> So if k=2, e.g. the result would ne

> This is

> This a

> This sample

> This and

> This nothing

> This else

> is a

> is sample

> is and

> .... etc. ..

> nothing else

#!/usr/local/bin/perl -w

use strict;

# Return an ordered list of the ordered combinations of $k

# integers out of $n integers, starting from 0.

sub combs {

my ($k, $n) = (shift, shift);

combs($k - 1, $n,

Quote:

}

--

(Just Another Larry) Rosler

Hewlett-Packard Company

http://www.hpl.hp.com/personal/Larry_Rosler/