Minimal Set

While TinyAPL is "tiny" in many ways, it is definitely not tiny in the amount of primitives it has. It might be interesting to find out what the minimal set of primitives is, i.e. the ones that can't be implemneted in terms of other primitives.

Aliases

Some of the primitives are pretty much simple applications of other primitives:

Default argument

Some primitives' monadic case is related to the corresponding dyad by either binding an argument or using a hook.

Combinators

All combinators can be rewritten using trains, as described in Combinators ↔ Trains.

Promote, Demote, Rerank

Promote is {⍵⍴⍨1⍪⍴⍵}.

Demote is

{ 0=ϼ⍵: ■⍵
⋄ 1=ϼ⍵: ■⊃⍵
⋄ ⍵⍴⍨(×⍆2↑⍴⍵)⍪2↓⍴⍵ }

ϼ Rerank is

{ ⍺=ϼ⍵: ■⍵
⋄ ⍺>ϼ⍵: ■⍺ ∇ ∧⍵
⋄ ⍺ ∇ ∨⍵ }

Set operations

Comparisons

All comparisons can be reconstructed from just = Equal To and  Less Than or Equal To.

Similarly, TAO comparisons can be reconstructed from  Identical and  Precedes Or Identical.

But TAO comparisons can be reconstructed from grading:

Min/max are also easy:

Floor and Round

Floor is "complex floor":

{ RealFloor←1∘|⊸-
⋄ x←1|ℜ⍵
⋄ y←1|ℑ⍵
⋄ p←(ℜ⍵)⊕⍥RealFloorℑ⍵
⋄ 1>x+y: ■p
⋄ x≥y: ■p+1
⋄ p+0ᴊ1 }

Round is componentwise round: ⦅ℜ⋄⊕⍥(⌊⍤+∘0.5)⋄ℑ⦆

Reduce

Reductions are special cases of folds where the initial value is the first/last cell of the array.

Remainder, GCD and LCM

Inner Product and Table

Tally and Depth

Tally is ⦅⊃⋄0⋄⍪⍨⋄⍴⦆

Depth is

{ (0≡ϼ⍵)∧⍵≡⊂⍵: ■0
⋄ 0≡ϼ⍵: ■1+∇⊃⍵
⋄ 0∊⍴⍵:■1
⋄ 1+⌈⍆∇ᑒ¨,⍵ }

Repeat and Until

Monadic  Repeat is _{ 0=⍵⍵: ■⍵ ⋄ ⍶⍶ _∇_ (⍵⍵-1) ⍶⍶ ⍵ }_; dyadic is an application of  Bind.

Similarly, monadic  Until is _{(⍶⍶ ⍵) ⍶⍶ _{ ⍺ ⍹⍹ ⍵: ■⍺ ⋄ (⍶⍶ ⍺) ⍶⍶ _∇_ ⍹⍹ ⍺ }_ ⍹⍹ ⍵}_; dyadic as above.

Half Pair and Pair