Fizz Buzz Function

If we implement Fizz Buzz without using ⎕SWITCH functions or nested ⎕IF functions, it will look like this:

FZBZ: υ4 → κ[?] ← {
    FZBZ: ⟨κ[?]⟩[4] ← ⟨"NOPE"⟩ ⟨"FIZZ"⟩ ⟨"BUZZ"⟩ ⟨"FIZZBUZZ"⟩;
    FIZZ: υ4 ← IF:υ3 ⟨(ω|3)=0, 1, 0⟩;
    BUZZ: υ4 ← IF:υ3 ⟨(ω|5)=0, 2, 0⟩;
    ⟨ANS⟩ ← FZBZ[FIZZ + BUZZ];
    ANS;
}
⎕ ← ⎕FZBZ 1+⍳1000;
"FIZZBUZZ"
"NOPE"
"NOPE"
"FIZZ"
"NOPE"
"BUZZ"
"FIZZ"
"NOPE"
"NOPE"
"FIZZ"
"BUZZ"
"NOPE"
"FIZZ"
"NOPE"
"NOPE"
"FIZZBUZZ"
...

Trump Card Generation

SUITS: κ[4] ← "♡◇♧♤";a
NUMS: κ[13] ← "A234567890JQK";
TRUMP: ⟨κ, κ⟩[52] ← SUITS .& NUMS;
⎕ ← TRUMP;
⟨'♡','A'⟩ ⟨'♡','2'⟩ ⟨'♡','3'⟩ ... ⟨'♤','J'⟩ ⟨'♤','Q'⟩ ⟨'♤','K'⟩

shuffling:

SUITS: κ[4] ← "♡◇♧♤";
NUMS: κ[13] ← "A234567890JQK";
TRUMP: ⟨κ, κ⟩[52] ← SUITS .& NUMS;
⎕ ← {ω[?ρω]} {(×/ρω)ρω} TRUMP;
⟨'♢','K'⟩ ⟨'♡','5'⟩ ⟨'♢','2'⟩ ... ⟨'♡','J'⟩ ⟨'♤','A'⟩ ⟨'♧','K'⟩

Tic Tac Toe

At 7.3.9. and 7.3.11. , I showed an example of binary file output.
Actually, this is not just arbitrary data. It’s actually a binary sequence representing the state of a Tic-Tac-Toe board.

Look at this:

⊤ ⊤ ⊤ ⊥ ⊤ ⊤ ⊤ ⊥ ⊤ | ⊤ ⊥ ⊤ ⊤ ⊥ ⊥ ⊤

\[ \begin{array}{|c|c|c|} \hline 〇 & × & 〇 \\ \hline & 〇 & × \\ \hline × & & 〇 \\ \hline \end{array} \]

Furthermore, this is a variable-length format.
If we examine the first 9 bits from the beginning, you should be able to understand what they represent.
The part before the delimiter is fixed, while the part after is variable. It is easy to imagine that the length ranges from a minimum of 9 bits to a maximum of 18 bits.
Count the number of true values in the first part. If that number matches the number in the second part, the condition is satisfied.

I’ll implement only the decoder for this. I encourage you to try implementing the encoder yourself.

ttt_decorder.ropl

⎕IMPORT ← "FS";

PATH ← "PATH/TO/FILE";

TTTBA ← ⎕FGETB PATH; ⍝ TIC TAC TOE BINARY ARRAY ⍝

⎕ASSERT ← ⟨ρTTTBA ≥ 9, "TIC TAC TOE BINARY ARRAY OUT OF RANGE ERROR: 9 OR MORE"⟩;
⎕ASSERT ← ⟨ρTTTBA ≤ 18, "TIC TAC TOE BINARY ARRAY OUT OF RANGE ERROR: 18 OR LESS"⟩;

TTTF ← TTTBA[ι9];
TTTL ← TTTBA[10 + ι ρTTTBA - 9];

⎕ASSERT ← ⟨(ρ=TTTF) = ρTTTL, "TIC TAC TOE BINARY ARRAY VALIDATION ERROR: DO NOT MATCH BOTH SIZES ({ρ=TTTF}, {ρTTTL})"⟩;

TTTBB: β[3 3] ← 3 3 ρTTTF;
TTTHM: ⟨υ[2], β⟩[ρTTTL] ← {⟨=TTTBB[ω]⟩&⟨TTTL[ω]⟩}⍤0 ιρTTTL;

TTTHIT: ⟨υ[2], β⟩, υ[2] → β ← {
    P, _ ← α;
    P ≡ ω;
}

TTTMAP: υ[2] → κ: ← { ⎕IF:κ ⟨∨/ TTTHIT TTTHM, ⎕IF:κ ⟨B, "1", "0"⟩, "_"⟩ }
TTT: κ[3 3] ← {TTTMAP ω}⍤1 ((ι3)&.ι3);
⎕ ← TTT;
1 0 1
_ 1 0
0 _ 1