You might want to encapsulate the code under a sub, where one of parameters will be the distance function name. Other parameters could also be named parameter, as well. This is a very widely spread perl technique. For example, this sub would be called then as
my $result = cluster(
num_clusters => 5,
data => [1,2,3,4,5],
distance => 'procrustes'
);
This way, if the programmer does not specify all parameters, there will be subsituted sensible defaults ( possibly different for each distance ). Also the sub can die if there's not enough or invalid parameters given. | [reply] [d/l] |
| [reply] |