Math::N...q::Cubes(3)
π Math::N...q::Cubes β the perl manual page, bestie edition
okay so real talk, this page is Math::N...q::Cubes(3) from the User Contributed Perl Documentation, and it is exactly what it says on the tin: cubes. like, i**3. iconic behaviour, honestly.
β¨ NAME β¨
Math::NumSeq::Cubes β cubes i**3 π²
πΈ SYNOPSIS πΈ
the little "here's how you summon it" moment:
use Math::NumSeq::Cubes;
my $seq = Math::NumSeq::Cubes->new;
my ($i, $value) = $seq->next;
that's it. that's the whole vibe check. π¦
π DESCRIPTION π
so it's the sequence of cubes, i**3, and they go like this:
0, 1, 8, 27, 64, 125, ...
no cap, that's the entire concept. 0 cubed is 0, 1 cubed is 1, 2 cubed is 8, and it keeps going up forever. main character energy from a sequence that literally just multiplies a number by itself three times. periodt. π
π FUNCTIONS π
heads up bestie: for the behaviour that all the sequence classes share, go look at "FUNCTIONS" in Math::NumSeq. this page only covers the stuff that's special to Cubes.
$seq = Math::NumSeq::Cubes->new ()β makes you a brand new sequence object and hands it over. that's your girl. π
π§ Iterating
($i, $value) = $seq->next()β gives you the next index and the next value in the sequence, together, as a pair.
okay important: if$valueoverflows a usual Perl UV integer, the return gets promoted toMath::BigIntso that all the bits are preserved. she will not let a single bit go missing. π«Ά
$seq->seek_to_i($i)β jumps your current position in the sequence over to$i. the very next time you callnext(), you'll get$iand its matching value. like teleporting but for indices.$seq->seek_to_value($value)β moves your current position so that the nextnext()call gives you$value. and if$valueis not a cube? then you get the next cube above$value. no exact match, no problem, she'll find you the one after. β¨
π Random Access
$value = $seq->ith($i)β returns"$i*$i*$i". the cube of$i, right there, no scrolling required.$bool = $seq->pred($value)β returns true if$valueis a cube. true/false, in and out, love that for you.$i = $seq->value_to_i_ceil($value)and$i = $seq->value_to_i_floor($value)β these give you the cube root of$value, rounded up (ceil) or rounded down (floor) to the next integer. two flavours, same energy. π$i = $seq->value_to_i_estimate($value)β hands you an estimate of theithat corresponds to$value. it's a vibe, not a promise. π
π SEE ALSO π
Math::NumSeqMath::NumSeq::Squares
(go read those too, they're the friend group.)
π HOME PAGE π
<http://user42.tuxfamily.org/math-numseq/index.html>
π LICENSE π
Copyright 2010, 2011, 2012, 2013, 2014, 2016, 2019, 2020 Kevin Ryde
Math-NumSeq 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-NumSeq 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-NumSeq. If not, see <http://www.gnu.org/licenses/>.
fr fr, that "WITHOUT ANY WARRANTY" bit is doing a lot of heavy lifting β it's not a cute little disclaimer, it's the whole point. read it. π
and that's the page, bestie!! this was perl v5.42.0, dated 2025-07-25 β so when you're out here cubing numbers, just know the manual said it first. mwah. πβ¨π
π¦ where this page comes from
- fedora 43: perl-Math-NumSeq 75-11.fc43 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms