www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Some combinatorics?

reply bearophile <bearophileHUGS lycos.com> writes:
I'd like to write combinations, permutations, etc ranges (generators), for
std.algorithm or for a small std.combinatorics Phobos module. (I have written
this code time ago for dlibs1 in D1).

I have found some small performance problems in converting the opApply
combinatorics code to the Range protocol.

Are you interested in this module (or in just those few generators for
std.algorithm)? I find them often useful.

Bye,
bearophile
Apr 02 2011
parent dsimcha <dsimcha yahoo.com> writes:
== Quote from bearophile (bearophileHUGS lycos.com)'s article
 I'd like to write combinations, permutations, etc ranges (generators), for

code time ago for dlibs1 in D1).
 I have found some small performance problems in converting the opApply

 Are you interested in this module (or in just those few generators for

 Bye,
 bearophile

I've included these in my dstats lib, but my implementations admittedly aren't very well thought out. (I wrote these in 2008 before ranges and shoehorned them into ranges. I never fixed them because I kept thinking I or someone else was going to rewrite them and that hasn't happened so far.) I need this often enough that I'd be interested in having them in Phobos. Some code by Philippe Sigaud does it better than my implementations (http://svn.dsource.org/projects/dranges/trunk/dranges/docs/algorithm.html) and is Boost licensed. He was thinking of getting parts of this lib into Phobos, but I don't know what the status of that is. If this project is abandoned and you like it, you could take it over, or you could just write your own. One important issue is whether the number of elements for a combination should be specified at compile time (more efficient), runtime (more flexible) or both (possibly bloated). As far as where these should go, I'd say either std.range or a module publicly imported by std.range. They deal with range topology.
Apr 02 2011