31 Oct 2011 14:37:48 UTC
- Distribution: Math-Inequalities-Parser
- Module version: 0.002
- Source (raw)
- Browse (raw)
- How to Contribute
- Testers (585 / 1 / 0)
- KwaliteeBus factor: 7
- 94.64% Coverage
- License: perl_5
- Download (19.61KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
- TYPES OF INEQUALITY
- COPYRIGHT & LICENSE
Math::Inequalities::Parser - Minimum and maximum values allowed by an inequality.
use Math::Inequalities::Parser; my ($min, $max) = parse_inequality( ' 10 < n < 20 ' ); # $min = 11 # $max = 19
Tiny library for parsing integer maximum and minimum out when given an arbitrary inequality.
Because getting this simple thing right was far harder than it looked, and I never want to have to think about it again.
Parses an inequality string and returns a list of two values, the minimum and the maxium value that string will allow.
The simplest type, a single value, e.g.
42 = Min 42, Max 42.
Maximum is VALUE - 1, Minimum is undefined, e.g.
n < 42 = Min undef, Max 41.
Minimum is VALUE +1, Maximum is undefined, e.g.
n > 42 = Min 43, Max undef.
Maximum is VALUE, Minimum is undefined, e.g.
n < 42 = Min undef, Max 42.
Minimum is VALUE, Maximum is undefined, e.g.
n > 42 = Min 42, Max undef.
Handled as above, but with minimum and maximum reversed as expected.
Minimum is VALUE1 + 1, maximum is VALUE2 - 1, e.g
42 < n < 200 = Min 43, Max 199.
- Does not handle
VALUE1 <= n <= VALUE2or similar. Patches welcome.
- Does not complain at impossible
<VALUE1 < n < VALUE 2> combinations (e.g.
5 < n < 4) which result in a higher minumum than the maxiumum. Patches welcome.
- Does not work with negative numbers. Patches welcome.
- Always uses
nas the number identifier, this should be configureable at import time.
- Uses Exporter (should use Sub::Exporter)
- DOES NOT work with floating point numbers. I consider this a feature.
Tomas Doran (t0m)
Copyright 2011 the above author(s).
This sofware is free software, and is licensed under the same terms as perl itself.
Module Install Instructions
To install Math::Inequalities::Parser, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Math::Inequalities::Parser
For more information on module installation, please visit the detailed CPAN module installation guide.
|s||Focus search bar|
|?||Bring up this help dialog|
|g p||Go to pull requests|
|g i||go to github issues (only if github is preferred repository)|
|g a||Go to author|
|g c||Go to changes|
|g i||Go to issues|
|g d||Go to dist|
|g r||Go to repository/SCM|
|g s||Go to source|
|g b||Go to file browse|