On May 24, 2006, at 10:21, Smylers wrote:
Xavier Noria writes:
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. ... Also there'd be lack of
symmetry about the input and output structures...
Why?
In the case where the user supplied a hash surely you could remember
this and return the results as a hash too?
Certainly.
That makes sense in combinations() and partitions(). In the rest
inputs may be sets (except for derangements()) and outputs are
sequences by definition (except for combinations_with_repetition()),
so the difference in structures would be in general natural, not a
lack of symmetry.
From a logical point of view it makes perfect sense, and I can
imagine myself passing a hashref and expecting hashrefs in turn. The
special cases and their consequences in documentation and easy of use
make me be careful opening the API that way.
-- fxn