3 ms·
"Rank" means the number of dimensions of an array. So "rank polymorphism" means being able to write expressions that work correctly regardless of how many dims
by jph00 1y ago
"Rank" means the number of dimensions of an array.
So "rank polymorphism" means being able to write expressions that work correctly regardless of how many dims the arrays involved have.
For example, in numpy you can write a function that handles both lists and matrices automatically, by taking advantage of broadcasting. (The J language takes this idea a lot further -- numpy is a fairly minimal implementation of the idea.)
- hinkley 1y agoThat just sounds like someone needing to feel smarter than 'multidimensional arrays' sounds. Which if you ask the average unskilled laborer, already sounds pretty damned fancy.
- diziet_sma 1y agoIt's not the same thing as multidimensional arrays though. You can have multidimensional arrays without rank polymorphism. Rank polymorphism makes working with multidimensional arrays much easier because you can write one function which works over input arrays with different shapes.