▲ | simiones 5 days ago | |||||||||||||||||||||||||
Would this work for something like linear algebra? Could it support multiplying two 3x3 matrices where each cell can have a different dimension, and only work if they are compatible? | ||||||||||||||||||||||||||
▲ | antononcube 4 days ago | parent | next [-] | |||||||||||||||||||||||||
Yes you can do that (easily) with Wolfram Language (aka Mathematica.) Here is an example:
See the corresponding screenshot: https://imgur.com/aP9Ugk2 | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||
▲ | boscillator 5 days ago | parent | prev | next [-] | |||||||||||||||||||||||||
This is something I always feel is missing from unit libraries. | ||||||||||||||||||||||||||
▲ | cosmic_quanta 5 days ago | parent | prev [-] | |||||||||||||||||||||||||
That's a great question. Haskell has arrays and matrices of homogeneous types, so it wouldn't work by default. If you needed this kind of functionality, you would have to create your own Matrix type which would look very similar to a 9-tuple, and then define matrix multiplication. It would then be possible to encode the dimensional constraints in the type signature, but it's already quite involved for 2x2 matrices:
I can't imagine for 3x3. | ||||||||||||||||||||||||||
|