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

Dear Perl champs,

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.



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

Thanks a lot and looking foward to your suggestions.
    Armin



Fri, 30 Nov 2001 03:00:00 GMT  
 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/



Fri, 30 Nov 2001 03:00:00 GMT  
 Perl tuning/speed question: all subsets of a set of length k -- keeping the inital order

: Subject: Perl tuning/speed question: all subsets of a set of length k -- keeping

: 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.

   Where is the Perl code that your Subject says you want "tuned"?

   I think you forgot to include it...

--
    Tad McClellan                          SGML Consulting

    Fort Worth, Texas



Fri, 30 Nov 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Simple Subset Question

2. Subset Question

3. Problem with setting the Page Length

4. Setting up a variable length format at runtime

5. unknown warning when setting scale length

6. AWK vs PERL speed question

7. Perl memory and speed questions (Lots of code)

8. Small subset of Perl....

9. question about speeding perl development

10. MSDOS perl -- can't init loader

11. desperate: perl scripts called from init.d/... scripts

12. perl oracle speed question

 

 
Powered by phpBB® Forum Software