in reply to Bottom-Up Data Mining with Perl
It could also be written as a hash of hashes, but I think that shows what I mean.. I also avoided adding the logic to determine if its a leap year, and appropriatly set Feb->1, as I thoroughly *hate* that aspect of our calendar system..%months = ( Jan => [1, '31'], Feb => [2, '' ], Mar => [3, '31'], Apr => [4, '30'], May => [5, '31'], Jun => [6, '30'], Jul => [7, '31'], Aug => [8, '31'], Sep => [9, '30'], Oct => [10, '31'], Nov => [11, '30'], Dec => [12, '31'] ); # Get number of days in Jan $days = $months{Jan}->[1];
The possibilities are endless.. I see alot of people who dont fully utilize the data structures to represent their data and how it relates to itself.. Maybe they attempt to have a bunch or arrays and loop through one while pulling data from another (nothing wrong with this approach), as opposed to slapping the data into a single array of arrays.# in numerical order for ( sort { $a->[0] <=> $b->[0] } keys %months ) { # or reversed for ( sort { $b->[0] <=> $a->[0] } keys %months ) {
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Bottom-Up Data Mining with Perl
by tachyon (Chancellor) on Mar 05, 2003 at 23:52 UTC | |
by zengargoyle (Deacon) on Mar 06, 2003 at 00:12 UTC | |
by tachyon (Chancellor) on Mar 06, 2003 at 00:55 UTC | |
by zengargoyle (Deacon) on Mar 06, 2003 at 03:37 UTC |