On May 24, 2006, at 4:37, Ken Williams wrote:

BTW, Xavier & David both: The proposed interface for enumerating the set partitions uses array refs, but sets in perl are more naturally represented using hashes. I'd suggest re-implementing in terms of hashes, or perhaps giving it a complete-enough OO interface that hides the actual implementation structure.

The use of arrays in the (whole) interface of Algorithm::Combinatorics is a decission not based on the underlying implementation, but on the fact that an array is a valid way to _pass_ a handful of elements, and one that allows talking about lexicographic order in the output, which is intuitive. Related to this, the module outputs arrays, not hashes (when a hash would make sense).

The API has evolved quite uniformly by now on purpose. One of the objectives is that you open the documentation and see ipso facto how to use anything, that's behind the procedural approach, and behind the uniform notation and usage.

But that's a good point, instead of requiring the user to pass [keys % set] if he works with a hash, I could add a little sugar and accept hashrefs in addition to arrayrefs. In that case the contract would be we'll work on their keys and order in the output is undefined. The only subroutine that cannot accept a hashref is derangements(), I need to ponder whether I like having that exception in the API. Also there'd be lack of symmetry about the input and output structures.... I'll think about it.

-- fxn

Reply via email to