Source code for snippets ⋅ Twitter discussion ⋅ Reddit discussion ⋅ Linkedin discussion ⋅ Facebook discussion
It's recommended to refresh knowledge about representing objects and Kleisli morphisms before.
Alone is a covariant functor from Arrow into Arrow that could be represented/co-represented with Unit object:
We can use this simplest functor in a variety of functor composition schemes which are functors as well:
We are particularly interested in the last one - product composition. It's also a covariant functor from Arrow into Arrow but representing object is slightly different - Sum of Units:
Since natural transformations for covariant functor compositions defined inductively we can add more functors and representing object would be adjusted accordingly:
The good news is that we have literals for this kind of functor compositions - vectors:
Challenge: initialise vectors with 4/5/6 scalar values.
It's time to add more dimensions and start using matrices which are functor compositions of vectors:
Representing object for underlying functors are combined into a product:
Challenge: write some code to represent/co-represent matrices.
Here we initialise matrices vector by vector:
Matrix with the same set of elements but different dimensions:
Transposing and traversing are similar operations in that sense that we swap functors in both cases:
So far we covered scalars, vectors and matrices - these could be generalised via tensors:
This is how it's going to look like in terms of functors:
Challenge: write some code to represent/co-represent tensors of rank 3.
Take a look the these snippets below. What kind of operations in linear algebra do these transformations correspond to?
Challenge: why the code below doesn't make sense?
For all challenges in this article use special executable for snippets.