( Hailstone function in Rejoice )

n^7 @Hailstone
.#n .\n

done [n^2]/[n^2 done] [Halt]/done

@Parity
[a^2 Parity]/n^2
even [odd n]/[even n]
@Parity.A->N [n Parity.A->N]/a

[Even]/even [Odd]/odd

@Even ( n = n/2 )
[a Even]/n^2
@Even.A->N [n Even.A->N]/a
Hailstone

@Odd ( n = 3n + 1 )
[a^3 Odd]/n a
@Odd.A->N [n Odd.A->N]/a
Hailstone

@Halt

(cc @neauoire)

@andnull aye X) you're doing backflips already, meanwhile I'm eating putty..

red^2 blue^2 yellow^2
violet/[red blue]
green/[blue yellow]
orange/[red yellow]
black/[violet green orange]

🎨

@neauoire I did write a whole game in Vera for December Adventure 2024

One bottleneck became things like "your rules to check for the parity of a register is 40 rules deep, but there are 5 step. So, it's really 200 rules deep. But, it is also part of a hot-loop and takes 20,000 rules to finish".

Second issue was things like "rules submit all values in one transaction". So, you had to awkwardly spread actions over many rules to enforce sequence of individual steps.

December Adventure 2024

@andnull you've been contending with this limitations much more than I have I think, a lot of the languages you've explored since Vera looks like stabs at cutting across large rulesets like that.

The hailstone function works amazingly well 🙌

@neauoire haha, yeah, I push the rule oriented approach to very hard limits. So, I have been doodling ways to mix and match things.

@neauoire Also, doing a hailstone makes me feel like comparing Rejoice to Forth and (rule-oriented) FRACTRAN is a bit of a disservice to the language. It has fractrans encoding of counter machines but is farm more direct, and definitely doesn't feel like handling forth or any stack-based language. It has a rather unique feel where every operation can be made conditional.

Makes me think of the work down with Vinegar or Prowl (if you remember that one from UberPyro). I think the conditionality of everything in Rejoice is its stand out feature. I think a real moment for me with Rejoice was in writing done [n^2]/[n^2 done] [Halt]/done. Something there just wholely unique about it.

Languages

Languages at Cat's Eye Technologies

Cat's Eye Technologies
@neauoire Feels like I am stack shuffling control-flow itself instead of data.

@neauoire I think what really made it connect tho was the fact I originally wrote:

done [n^2 continue]/[n^2 done]
[Halt]/done []/continue

refactoring that to just

done [n^2]/[n^2 done] [Halt]/done

feels like a holdover from Factran just dropped way in my brain. I am so used to every condition needing a dual countercondition I just reflexively wrote ever rule in pairs (including my math operations).

@andnull I've been thinking about some stuff, maybe you have come across this before or have some insight.

But I was thinking of allowing negative(signed) amounts.

So like n^-4 n^4 would yield 1/1, or identity [].

I'm not really sure if it's a good idea or not, but it's something that's like RIGHT THERE, I feel like it might go to fun places, has a way to indicate the "lack of something".

Just thought I'd share that idea with you, not sure if will implement or not, seems maybe more of a curiosity. I don't know how this will impact matching X)

@neauoire From the perspective of counter machines, signed counters can work. But it breaks down pretty badly if you allow it in Fractran's encoding scheme.

It means allowing fractions in the bag (2-1 = 1/2), it also opens a can worms around what [...]/x^-1 means. When I was messing with recipe books, I quickly found I needed <0, =0, and >0.

@neauoire Also, the counter machine construct when using >= as your comparison operator can handle a case stock Fractran cannot: 0 items in the bag. It's pretty easy to do something like [...]/x^0 when x^0 is not compressed to the same "location" (in this case 1) as y^0.
@neauoire Basically, if you want to experiment with matching behavior beyond just positive counters (as FRACTRAN cannot match on 0 items, they all map to 1), then you have to engage with the underlying computer system fractran encodes: counter machines.

@andnull I think until I have a clearer idea of what a negative count match "means", I'm not going to push further, but have you come across something that works that way with counter machines I could use to try this idea? Or do they always have all the different comparison operators to handle that sort of things?

I was just looking if petri nets and that sort of stuff had ways to handle the lack-of-something and there isn't much written about that.

@neauoire Logic systems don't like the idea of "this is not true". Generally, you lean on disjuctions "f(x) and nop(x) or h(x)" rather than not f(x) and h(x). This is why for my check on the hailstone function I phrased it like this:

done [n^2]/[n^2 done] [Halt]/done

I have to construct a token representing a choice, the destroy it to represent its negation. With a "not" in Fractran, I could have written:

[Halt]/n^0

However, due to Fractran's encoding, this is the same as [Halt]. *^0is always True.

@neauoire This is kinda what I meant by "shuffling control-flow". As you have to create resources to take a transition, then consume them to make that transition fail.

@neauoire This is also true of Petri nets. They are all about tokens flowing through a system. It creates a contradiction in the model if a transition can assert you "don't have any tokens".

How can you have a token representing the lack of tokens?

@andnull @neauoire additional alphabet for untokens, more rules for transition

@atax1a @neauoire yup, and that kinda lead me down the rabbit hole of Type-4 grammars (which there seems to be exactly one citation for so). @june had built a little bit-oriented stack machine. And it could only make decision on 1 as 0 wasn't "in the language". However, I discovered you could expand the language using an encoding scheme such as 1 -> 10 and 0 -> 01.

Basically, you always have to encode unmatchable information into the system by expanding your symbol set.

https://www.sheeeeeeeep.art/finite-choice.html

Finite Choice: Type-4 Grammars

@andnull @neauoire the other option we see is to allow transition on no tokens, analogous to the difference between DFA and NFA
@atax1a @neauoire and that's where you have to break from strict Fractran cause 2^0 = 3^0 = 5^0 = ... = 1 and then everything implodes.

@andnull @atax1a okay thanks for all this, it makes it all pretty clear, I don't need negative exponents, too much noise to an otherwise OISC :)

I've been implementing a tropical arithmetic evaluator and I had to make a GDC() implementation and it looks so cute
https://wiki.xxiivv.com/etc/rejoicerepl/#gcd

Rejoice Interpreter

By Hundred Rabbits

Varvara5
@neauoire I would say 0 is doable with only >=, but negatives are a clusterfuck that introduced special cases and 2 or 3 way logic. Open topics for anyone looking to extend Rejoice.