perlancar > Number-Closest-NonOO > Number::Closest::NonOO

Download:
Number-Closest-NonOO-0.06.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.06   Source  

NAME ^

Number::Closest::NonOO - Find number(s) closest to a number in a list of numbers

VERSION ^

This document describes version 0.06 of Number::Closest::NonOO (from Perl distribution Number-Closest-NonOO), released on 2015-09-03.

SYNOPSIS ^

 use Number::Closest::NonOO qw(find_closest_number find_farthest_number);
 my $nums = find_closest_number(number=>3, numbers=>[1, 3, 5, 10], items => 2); # => [3, 1]

 $nums = find_farthest_number(number=>3, numbers=>[1, 3, 5, 10]); # => 10

DESCRIPTION ^

FUNCTIONS ^

find_closest_number(%args) -> any

Find number(s) closest to a number in a list of numbers.

Arguments ('*' denotes required arguments):

Return value: (any)

find_farthest_number(%args) -> any

Find number(s) farthest to a number in a list of numbers.

Arguments ('*' denotes required arguments):

Return value: (any)

FAQ ^

How do I find closest numbers that are {smaller, larger} than specified number?

You can filter (grep) your list of numbers first, for example to find numbers that are closest and smaller or equal to 3:

 my @nums = grep {$_ <= 3} 1, 3, 5, 2, 4;
 my $res = find_closest_number(number => 3, numbers => \@nums);

How do I find unique closest number(s)?

Perform uniq() (see List::MoreUtils) on the resulting numbers.

SEE ALSO ^

Number::Closest. Number::Closest::NonOO is a non-OO version of Number::Closest, with some additional features: customize handling NaN/Inf, find farthest number.

HOMEPAGE ^

Please visit the project's homepage at https://metacpan.org/release/Number-Closest-NonOO.

SOURCE ^

Source repository is at https://github.com/perlancar/perl-Number-Closest-NonOO.

BUGS ^

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Number-Closest-NonOO

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR ^

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2015 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: