Math::N...sciiSelf(3)

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

πŸ’– Math::N...sciiSelf(3) πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation and the module is called Math::NumSeq::AsciiSelf β€” yes the header got truncated to Math::N...sciiSelf(3) because man pages are dramatic like that πŸ’…. anyway. sit down, hydrate, we're learning about a sequence that is literally its own ASCII. no cap.


✨ NAME ✨

Math::NumSeq::AsciiSelf β€” the sequence that is its own ASCII digits 🫢 like it's self-referential AND self-sufficient, main character energy fr fr


🌸 SYNOPSIS 🌸

use Math::NumSeq::AsciiSelf;
my $seq = Math::NumSeq::AsciiSelf->new;
my ($i, $value) = $seq->next;

that's it. that's the whole vibe. three lines and you're in πŸ’–


πŸ¦‹ DESCRIPTION πŸ¦‹

So. This is a sequence that is itself in ASCII. Sloane's OEIS says it's A109733 ✨

53, 51, 53, 49, 53, 51, 52, 57, etc

and here's the tea, bestie: the first value 53 is made of the digits 5,3 β€” and 5,3 in ASCII is the initial 53, plus 51 appended. That new 51 is digits 5,1, which is ASCII 53 and 49, and those get appended. Then those new digits 5,3,4,9 are ASCII 53,51,52,57 which get appended, and so on and so on, forever, like a group chat that never dies 😭

Notice (and this is the iconic part πŸ‘‘) that if you interpret the sequence values as ASCII, you get the digits of the sequence itself. And conversely, if you expand each value to its digits represented in ASCII, the sequence is left unchanged. It's giving self-portrait. It's giving mirror. It's giving ✨ recursive queen ✨

The default is digits in decimal. There's an experimental, mostly-working "radix" parameter so you can do it in other bases. Lowkey a few of them are boring though: bases 8, 12 and 16 end up as repetitions of a single value, which is not very interesting, I'm sorry, I said what I said πŸ’€. Bases 5, 9 and 13 have a choice of two starting self-ASCII values, but only the smallest is used for now. And in base 7, ith() is wrong, but next() is right πŸ™ˆ (more on that in BUGS, bestie, don't @ me).


πŸ’… FUNCTIONS πŸ’…

See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes. shared lore, iykyk 🌈

  • "$seq = Math::NumSeq::AsciiSelf->new ()" β€” create and return a new sequence object ✨ fresh out the box, no baggage

πŸŽ€ Random Access πŸŽ€

  • "$value = $seq->ith($i)" β€” return the $i'th member of the sequence. The first is i=1. one-indexed, we're not doing the zero thing here πŸ’–

⭐ FORMULAS ⭐

🧚 Ith

The doubling described above is the key to the sequence structure. Numbering from k=i-1, so k=0 is the first member, take the bits of k from high to low. Start with value 53. At each bit, expand the value to its digits in ASCII β€” so for example 53 -> 53,51. Then take the first or second according to whether the bit from k is 0 or 1. cute, right? a little bit-picking buffet πŸ“

πŸ”₯ Next

The bits of k for the ith calculation can be retained and incremented by a carry algorithm, rather than breaking down in each next() call. The two expanded ASCII values can be kept at each bit and selected by the bit value. efficiency slay πŸ’…

🌈 Radix

With the experimental "radix" parameter, for base 6 and smaller the ASCII expands to 3 or more values. For example 48 in binary is 110000, so six ASCII 49,49,48,48,48,48. The calculations are the same, but digits of that size rather than bits.

In base 7 the digit lengths vary, since 48=66[7] and 49=100[7], so for it the digit range depends on the expansion. That's fine for next() where the number of digits at each state is available, but how best might ith() notice the shorter count for zeros? πŸ€” an open question, a mystery, a little cliffhanger


πŸ’€ BUGS πŸ’€

ith() gives wrong values for the experimental "radix" parameter for radix 7. can('ith') returns false for that radix, as a way of saying ith() is not available. (Other bases are ok.)

so like, if you try to use ith() on radix 7, don't. it's lying to you 😭 the can('ith') returning false is the module being honest about its own limits, which is growth honestly. other bases are fine, we don't talk about radix 7 🫢


πŸ‘‘ SEE ALSO πŸ‘‘

Math::NumSeq β€” go read it, it's the parent, the blueprint, the origin story ✨


🌸 HOME PAGE 🌸

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

go click it, bestie, it's free real estate πŸ’–


πŸŽ€ LICENSE πŸŽ€

Copyright 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/>.

no warranty bestie, I cannot stress this enough, it's giving "use at your own risk" and honestly? respect πŸ’…

and that's the whole page!! πŸ¦‹ this was Math::N...sciiSelf(3) from perl v5.42.0, dated 2025-07-25 β€” thanks for reading, ily, go write a self-describing sequence, periodt βœ¨πŸ’–πŸŽ€

πŸ“¦ where this page comes from