cantor ← { , ((∘.× ∘ 1 0 1) ⍣ ⍵) 1 } cantor 3 1 0 1 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 1 0 1
Here's a Cantor set dfn. Notice that we only have to ravel once at the very end.
(cantor 3) ≡ , 1 0 1 ∘.× 1 0 1 ∘.× 1 0 1 1
But ∘.×
is associative! Let's do these outer products starting at the other side:
cantor ← { , 1 0 1 (∘.× ⍣ ⍵) 1 } cantor 3 1 0 1 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 1 0 1