Skip to content

Instantly share code, notes, and snippets.

@peschwa
Created August 24, 2025 07:29
Show Gist options
  • Select an option

  • Save peschwa/7c0e8e12e6a02e2fbc31f70ca185b6cd to your computer and use it in GitHub Desktop.

Select an option

Save peschwa/7c0e8e12e6a02e2fbc31f70ca185b6cd to your computer and use it in GitHub Desktop.
use v6;
unit module Math::Hessification;
#| why else do we have -0..?
my &sign = -> Numeric $x {
$x >= 0 ?? 1 !! -1
}
#| equally tempered
my $*TOLERANCE = (2**(1/12))/100e0;
role SteppenNum does Numeric does Positional[Int] is export {
#| canonical minimum
has $.pivot = 4;
multi method log(SteppenNum:D: ) {
return [] but Inf if self == 0;
nextsame;
}
multi method log(SteppenNum:D: SteppenNum $base) {
return [] but NaN if $base == 0;
nextsame;
}
only method keys(::CLASS: ) {
<<+0+0i +1+0i -1+0i -1-1i +1+1i +0+1i +0-1i>>
}
multi method AT-KEY(Complex \position) {
given position {
when +0+0i { self }
when +1+0i { self.reduct }
when -1+0i { self.deduct }
when -1-1i { self.deflect }
when +1+1i { self.product }
when +0+1i { self.reflect }
when +0-1i { self.refract }
}
}
#| evening
#| condenses on the boundary
method reduct(:$id = False) {
my $val = $id ?? $.pivot !! self;
my $div = log($.pivot,
sum(self.reflect(:1id), self.reflect(:1id)));
($val / $div).narrow but SteppenNum($.pivot)
}
#| night
#| approaches on the heels of causality
method deduct(:$id = False) {
my $val = $id ?? $.pivot !! self;
($val * self.refract(:1id) + sign(self) * self.reflect(:1id)).narrow
but SteppenNum($.pivot)
}
#| morning
#| fills the inside from the outside
method product(:$id = False) {
my $val = $id ?? $.pivot !! self;
($val * self.reduct(:1id)) but SteppenNum($.pivot)
}
#| day
#| grows towards reunion
method deflect(:$id = False) {
my $val = $id ?? $.pivot !! self;
($val - sign(self) * self.reflect(:1id))
/ self.refract(:1id) but SteppenNum($.pivot)
}
#| the relative complex unity
#| or rotational overlap
method reflect(:$id = False) {
my $val = $id ?? self.pivot !! self;
($val / $.pivot * i ** $val).narrow but SteppenNum($.pivot)
}
#| the missing linear step
#| i.e. `3` for `(4 2 1)`, or `6` for `(8 4 2)` etc.
method refract(:$id = False) {
(self.reduct(:id(!$id)) + self.reflect(:id(!$id)))
but SteppenNum($id ?? self !! $.pivot);
}
multi method gist(SteppenNum:D: ) {
my $s = Complex(self);
return $s.re.fmt("%.2f") ~"+i"~ $s.im.fmt("%.2f");
# self.round.gist
}
#| standard collatz step
method standard {
self %% self.reduct ?? self.reduct !! self.deduct;
}
#| traumatic fractal escalation
#| as per Taylor Hebert and Queen Administrator
method hebert {
self.deduct * self.deduct.refract(:1id) but SteppenNum($.pivot)
}
#| patterns from noise
#| as per Turing patterns and Church universality
method turing {
((self.reflect + self.refract) but SteppenNum($.pivot)).product
}
#| rigorously justified preening
#| as per Galois and Narcissus
method galois {
self.deflect.reflect.reduct
}
#| playing chicken with the void
#| as per Diogenes and to get to the other side
method diogenes {
my $self = self but SteppenNum($.pivot*2);
self.product * (self.refract/self.reflect) but SteppenNum($.pivot)
}
#| everything in the calm before the anacrusis
#| as per Ada Lovelace who first dreamt of music
method lovelace {
(self.reflect + self.reduct + self) but SteppenNum($.pivot)
}
#| anchoring on both sides
#| as per Marion Wheeler, and SCP-Mu-EX
method wheeler {
((self.reflect - self.refract) / self.reduct) but SteppenNum($.pivot)
}
#| you know Her
#| just as She knows you
method lilith {
((self - self.reflect) but SteppenNum).deflect
}
#`{{{ too dramatic...
#| heute nacht, von vier uhr an
proto method perform(*@_, *%_) { * }
multi method perform(::?CLASS:D: @steps) {
my $self = self;
for @steps -> $step {
print $self.gist ~ " ~> " ~ $self[$step].gist ~ ". ";
$self = $self[$step]
}
$self
}
#| nur fuer verrueckte
multi method perform-archetypes(@steps, Bool :$mythic) {
my $self = self;
for @steps -> $step {
print "behold! " ~ $self.^find_method("{$step}").WHY ~ ": ";
print $self.gist ~ " ~> " ~ $self."{$step}"().gist ~ "\n";
$self = $self."{$step}"()
}
$self
}
#| eintritt kostet den verstand
method personality(:$id, :$me, :$us) {
my &id = self.^find_method($id);
my &me = self.^find_method($me);
my &us = self.^find_method($us);
-> SteppenNum $x {
me(id($x)) * me(us($x)) but SteppenNum($x.pivot)
}
}
}}}
}
my \fourteen = 13 but SteppenNum(7);
say fourteen{fourteen.keys};
#`[[[ output:
(14.00+i0.00 4.99+i-11.30 41.82+i-159.22 0.22+i1.18 34.91+i-79.11 -2.00+i0.00 2.49+i-6.65)
]]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment