Math::N...q::Cubes(3)

πŸ“¦
version 75 Β· 2 versions
, in fedora 43

πŸ’œ 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 $value overflows a usual Perl UV integer, the return gets promoted to Math::BigInt so 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 call next(), you'll get $i and its matching value. like teleporting but for indices.
  • $seq->seek_to_value($value) β€” moves your current position so that the next next() call gives you $value. and if $value is 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 $value is 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 the i that corresponds to $value. it's a vibe, not a promise. 😌

πŸ‘€ SEE ALSO πŸ‘€

  • Math::NumSeq
  • Math::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