Math::...eneric(3pm)

πŸ“¦
version 129 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Math::PlanePath::Base::Generic β€” the lil helper bestie of the PlanePath universe πŸ’–

okay so this is Math::...eneric(3pm) from the User Contributed Perl Documentation, and it's genuinely one of those "small but iconic" modules. let's get into it 🫢

✨ NAME ✨

Math::PlanePath::Base::Generic β€” various path helpers. that's it, that's the whole job description, and she does it flawlessly πŸ’…


🌸 SYNOPSIS 🌸

use Math::PlanePath::Base::Generic 'round_nearest';
$x = round_nearest($x);

like. that's the vibe. import one thing, round one number, go live your life πŸ¦‹


πŸ’œ DESCRIPTION πŸ’œ

so basically this is a little grab-bag of generic helper functions for the PlanePath code. they're built to work on plain Perl integers and floats, no drama, no fuss πŸŽ€

and in some cases there's also some special support for "Math::BigInt", because sometimes numbers are big and we respect that πŸ’–


🧚 EXPORTS 🧚

okay so nothing is exported by default β€” no sneaky auto-imports, she's polite like that. but every function below can be imported in the usual Exporter style, like so:

use Math::PlanePath::Base::Generic 'round_nearest';
⚠️ but NOT parameter_info_nstart0() and parameter_info_nstart1(), and there's a whole reason for that which we get to below. foreshadowing! πŸ’€

πŸ‘‘ FUNCTIONS πŸ‘‘

🌈 Generic 🌈

  • $x = round_nearest ($x) β€” returns $x rounded to the nearest integer ✨. and if $x is exactly half way, like 2.5, then it rounds upwards to 3. no banker's rounding nonsense here bestie, we go UP πŸ“ˆ
$x = round_nearest($x);
  • $href = Math::PlanePath::Base::Generic::parameter_info_nstart0()
  • $href = Math::PlanePath::Base::Generic::parameter_info_nstart1() β€” these two return an "n_start" parameter hashref that's suitable for use in a "parameter_info_array()", with a default of either 0 or 1 (hence the names, iykyk 😌).

for example, all alone:

# alone
package Math::PlanePath::MySubclass;
use constant parameter_info_array =>
  [ Math::PlanePath::Base::Generic::parameter_info_nstart1() ];

or hanging out with other parameters too:

# or with other parameters too
package Math::PlanePath::MySubclass;
use constant parameter_info_array =>
  [
   { name            => 'something',
     type            => 'integer',
     default         => '123',
   },
   Math::PlanePath::Base::Generic::parameter_info_nstart1(),
  ];
πŸŽ€ and here's the tea on why these two aren't exportable: this function is not exportable since it's meant for a one-off call in an initializer β€” so there's literally no need to import it for repeated use. she's a one-time appearance, main character energy, no recurring role 🌟

πŸ”₯ SEE ALSO πŸ”₯

  • Math::PlanePath
  • Math::PlanePath::Base::Digits
  • Math::PlanePath::Base::NSEW

the whole squad, fr fr πŸ’ž


🌈 HOME PAGE 🌈

<http://user42.tuxfamily.org/math-planepath/index.html>

go say hi, she doesn't bite πŸ¦‹


πŸ’… LICENSE πŸ’…

Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Kevin Ryde

This file is part of Math-PlanePath.

Math-PlanePath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

Math-PlanePath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Math-PlanePath. If not, see <http://www.gnu.org/licenses/>.

πŸ“œ yes bestie, that's the real license text, ALL CAPS WARRANTY DISCLAIMER and everything. respect the legal bits, they ate πŸ’―

aaaand that's the whole page πŸŽ€ this was Math::...eneric(3pm), rendered for perl v5.32.0, dated 2021-01-23. tysm for reading, go round some numbers to the nearest integer, mwah πŸ’‹βœ¨