The dot . can be used to realize different types of products. For example,
1 2 3 +.× 4 5 6
I assumed the semantics of a f.g b was: compute g(a[i], b[i]) then reduce using f. That is,
dot f g = f/a g¨ b ⍝ map g between a and b, and then reduce using f
To verify this, I wrote:
]display a ← ⍳ 4 ⋄ b ← 4 +⍳ 4 ⋄ I ← { ((⊂ ⍺), (⊂ ⍵))} ⋄ a I.I b
┌─────────────────────────────────────┐
│ ┌→────────────────────────────────┐ │
│ │ ┌→──┐ ┌→──────────────────────┐ │ │
│ │ │1 5│ │ ┌→──┐ ┌→────────────┐ │ │ │
│ │ └~──┘ │ │2 6│ │ ┌→──┐ ┌→──┐ │ │ │ │
│ │ │ └~──┘ │ │3 7│ │4 8│ │ │ │ │
│ │ │ │ └~──┘ └~──┘ │ │ │ │
│ │ │ └∊────────────┘ │ │ │
│ │ └∊──────────────────────┘ │ │
│ └∊────────────────────────────────┘ │
└∊────────────────────────────────────┘
We can clearly see the right-fold of the elements, as it first maps the I creating
(1 5) (2 6) (3 7) (4 8) and then folds using I creating the nested structure,
so my definition seems to work!
However, this does not work for matrices:
]display a ← 2 2 ⍴ ⍳ 4 ⋄ b ← 4 + 2 2 ⍴ ⍳ 4 ⋄ I ← { ((⊂ ⍺), (⊂ ⍵))} ⋄ a I.I b
┌→────────────────────────────────┐
↓ ┌→────────────┐ ┌→────────────┐ │
│ │ ┌→──┐ ┌→──┐ │ │ ┌→──┐ ┌→──┐ │ │
│ │ │1 5│ │2 7│ │ │ │1 6│ │2 8│ │ │
│ │ └~──┘ └~──┘ │ │ └~──┘ └~──┘ │ │
│ └∊────────────┘ └∊────────────┘ │
│ ┌→────────────┐ ┌→────────────┐ │
│ │ ┌→──┐ ┌→──┐ │ │ ┌→──┐ ┌→──┐ │ │
│ │ │3 5│ │4 7│ │ │ │3 6│ │4 8│ │ │
│ │ └~──┘ └~──┘ │ │ └~──┘ └~──┘ │ │
│ └∊────────────┘ └∊────────────┘ │
└∊────────────────────────────────┘
Interesting! so it seems to actually compute some sort of outer product between its elements in this case, and not a "fold"? My hypothetical definition of the . operator does not perform
the same operation:
]display a ← 2 2 ⍴ ⍳ 4 ⋄ b ← 4 + 2 2 ⍴ ⍳ 4 ⋄ I ← { ((⊂ ⍺), (⊂ ⍵))} ⋄ I/a I¨b
┌→────────────────────────────────┐
│ ┌→────────────┐ ┌→────────────┐ │
│ │ ┌→──┐ ┌→──┐ │ │ ┌→──┐ ┌→──┐ │ │
│ │ │1 5│ │2 6│ │ │ │3 7│ │4 8│ │ │
│ │ └~──┘ └~──┘ │ │ └~──┘ └~──┘ │ │
│ └∊────────────┘ └∊────────────┘ │
└∊────────────────────────────────┘
So, what are the actual semantics of .(dot) in APL? How would I discover this by myself?