-
-
31 Oct 2011 14:37:48 UTC
- Distribution: Math-Inequalities-Parser
- Module version: 0.002
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues
- Testers (583 / 1 / 0)
- Kwalitee
Bus factor: 7- 94.64% Coverage
- License: perl_5
- Activity
24 month- Tools
- Download (19.61KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- unknown
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Math::Inequalities::Parser - Minimum and maximum values allowed by an inequality.
SYNOPSIS
use Math::Inequalities::Parser; my ($min, $max) = parse_inequality( ' 10 < n < 20 ' ); # $min = 11 # $max = 19
DESCRIPTION
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.
FUNCTIONS
parse_inequality
Parses an inequality string and returns a list of two values, the minimum and the maxium value that string will allow.
TYPES OF INEQUALITY
VALUE
The simplest type, a single value, e.g.
42 = Min 42, Max 42
.n < VALUE
Maximum is VALUE - 1, Minimum is undefined, e.g.
n < 42 = Min undef, Max 41
.n > VALUE
Minimum is VALUE +1, Maximum is undefined, e.g.
n > 42 = Min 43, Max undef
.n <= VALUE
Maximum is VALUE, Minimum is undefined, e.g.
n < 42 = Min undef, Max 42
.n >= VALUE
Minimum is VALUE, Maximum is undefined, e.g.
n > 42 = Min 42, Max undef
.Cases with VALUE, followed by N.
Handled as above, but with minimum and maximum reversed as expected.
VALUE1 < n < VALUE2
Minimum is VALUE1 + 1, maximum is VALUE2 - 1, e.g
42 < n < 200 = Min 43, Max 199
.BUGS
- Does not handle
VALUE1 <= n <= VALUE2
or 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
n
as 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.
AUTHORS
Tomas Doran (t0m)
<bobtfish@bobtfish.net>
Dave Lambley
COPYRIGHT & LICENSE
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.
cpanm Math::Inequalities::Parser
perl -MCPAN -e shell install Math::Inequalities::Parser
For more information on module installation, please visit the detailed CPAN module installation guide.