5 ms·
Linear algebra got a lot easier for me when I realised that matrices are just linear functions, and matrix multiplication is function composition. Abstract alg
by evincarofautumn 12y ago
Linear algebra got a lot easier for me when I realised that matrices are just linear functions, and matrix multiplication is function composition.
Abstract algebra and category theory give you incredibly useful program and API structuring techniques; you can get lots of nice properties for free by following these well-worn existing patterns, even more so than OOP design patterns. We make use of them a lot in Haskell, but they’re basically language-agnostic.
Even simple algebraic manipulations, like noticing that “return” is distributive over a conditional:
if x then return y else return z
return (if x then y else z)
Are very useful for restructuring programs to be more readable.
- Natsu 12y agoThere's also this: http://www.haskell.org/haskellwiki/Curry-Howard-Lambek_correspondence http://www.haskell.org/haskellwiki/Curry-Howard-Lambek_corre...
- evincarofautumn 12y agoThis one is beautiful as well. It was mind-opening for me to think of types in terms of provability (intuitionistic/constructive logic) rather than truth (classical logic). The only way to prove that a function returning a value of type T actually halts (and therefore does not actually “return” bottom/void) is to run it and obtain that T value, i.e., to find the object that the type claims exists.
- rohitarondekar 12y agoFor the second return to work doesn't the if have to be an expression i.e return the result of evaluating either y or z as the result of the if expression? If the language has if statements like say Javascript then it won't work.
- evincarofautumn 12y agoYes. And that is why statement–expression distinctions are stupid, because they obscure these relationships. In C-land it would be “if-else” vs. “?:”.
- wolfgke 12y ago> Linear algebra got a lot easier for me when I realised that matrices are just linear functions, and matrix multiplication is function composition. As my former exercise instructor for linear algebra told to the math students at the beginning of the second semester: Those people who have not yet understood that matrices are more than a box of numbers are definitely at the wrong place here.