| ▲ | abcd_f 8 days ago |
| > User-Extensible Rank Polymorphism > IMO this is what makes something an array language. Great to hear. So what is it? |
|
| ▲ | preommr 8 days ago | parent | next [-] |
| Not op, but I assume it means that there's rank polymorphism (i.e. data can be of arbitrary dimensions, and there's support for things like functions working on both N-dimensions, without having to specify n, or maybe setting constraints on n), and that the polymorphism can be used on the programmer side (so it's not limited to just a handful of language builtins) through the oop equivalent of subclasses and interfaces. |
| |
| ▲ | goldenCeasar 8 days ago | parent [-] | | A question, would you interpret this as rank polymorphism? schema do
input do
array :regions do
float :tax_rate
array :offices do
float :col_adjustment
array :employees do
float :salary
float :rating
end
end
end
end
trait :high_performer, input.regions.offices.employees.rating > 4.5
value :bonus do
on high_performer, input.regions.offices.employees.salary * 0.25
base input.regions.offices.employees.salary * 0.10
end
value :final_pay,
(input.regions.offices.employees.salary + bonus * input.regions.offices.col_adjustment) *
(1 - input.regions.tax_rate)
end
result = schema.from(nested_data)[:final_pay]
# => [[[91_000, 63_700], [58_500]], [[71_225]]]
| | |
| ▲ | CraigJPerry 8 days ago | parent | next [-] | | I think i'm misunderstanding, rank is explicit throughout this example but i'm not familiar with this syntax (ruby maybe?) but whatever the case i don't see the rank polymorphism. If i'm reading the syntax correctly, this would translate in kdb/q to a raze (flatten) on the 3 dimensions (regions, offices, employees). Probably more likely to be expressed as a converge but in either case, the calculations here are not possible in a rank polymorphic way. | | |
| ▲ | goldenCeasar 8 days ago | parent [-] | | The broadcasting handles the rank differences automatically. When bonus (at employee level) multiplies with col_adjustment (at office level), each employee's bonus gets their office's adjustment applied, no flattening or manual reshaping. The structure [[[91_000, 63_700], [58_500]], [[71_225]]] was preserved. This is from a Ruby DSL I'm working on (Kumi). Probably the broadcasting semantics are very different from traditional rank operators in q/APL? Edit: I realized that I missed the input structure: Region 0: Office 0 has 2 employees, Office 1 has 1 employee
Region 1: Office 0 has 1 employee
| | |
| |
| ▲ | npalli 8 days ago | parent | prev [-] | | I didn't downvote but was utterly puzzled with your example. After your response below, it occurs to me that you are confusing Employee rank (a business concept) with Array rank a mathematical concept. Either that or it is very strange explanation for rank polymorphism. |
|
|
|
| ▲ | djoldman 8 days ago | parent | prev | next [-] |
| The programmer can define functions that operate on matrices without having to be explicit about the number of dimensions and possibly (types of data, size of data, or length). Example 1: A function that can take as input a 4x2x8 matrix or a 3x7 matrix. Example 2: A function that can take as input a 4x2x8 matrix and a 3x7 matrix and output a third matrix. |
| |
| ▲ | tomsmeding 8 days ago | parent | next [-] | | Rank polymorphism means that a function can be polymorphic in the additional dimensions of arrays. For example, if you write a function that takes a 2x3 and a 4x5 array, it can also work on 10x15x2x3 and 10x15x4x5 arrays by broadcasting. If rank polymorphism results in accepting both 4x2x8 and 3x7, then that means the function was a function on elements to begin with. Which is possible, but not the most interesting application of rank polymorphism. | | |
| ▲ | djoldman 8 days ago | parent [-] | | > Rank polymorphism means that a function can be polymorphic in the additional dimensions of arrays. For example, if you write a function that takes a 2x3 and a 4x5 array, it can also work on 10x15x2x3 and 10x15x4x5 arrays by broadcasting. Thanks, this is what I was ineloquently attempting to describe with "A function that can take as input a 4x2x8 matrix or a 3x7 matrix." |
| |
| ▲ | almostgotcaught 8 days ago | parent | prev [-] | | > A function that can take as input a 4x2x8 matrix and a 3x7 matrix and output a third matrix. which shows that this feature request is complete jibberish | | |
| ▲ | rscho 8 days ago | parent | next [-] | | Why gibberish ? It's a common feature in both array languages and Iverson ghosts, and many find it extremely useful. | |
| ▲ | tracker1 8 days ago | parent | prev [-] | | You mean like a "winner" function able to check for both Tic-Tac-Toe, a Connect Four field and a Similar 3D+ tower game? | | |
| ▲ | taeric 8 days ago | parent [-] | | I'm not sure I follow? The "winning" condition is different in all of those examples? | | |
| ▲ | tracker1 8 days ago | parent [-] | | X adjacent cell values in an N dimensional array? For tic tac toe, it's 3 in a row, for connect 4 it's 4 in a row. | | |
| ▲ | taeric 7 days ago | parent [-] | | Fair enough, I guess. The "available moves" would be dramatically different, such that I'm not clear I see much of a win on this reuse. But, yeah, fair enough. | | |
| ▲ | tracker1 7 days ago | parent [-] | | It was just the simplest case I could think of that would be reasonable. I'm not a heavy enough pure math guy to really get how an Array centric language is even all that valuable myself TBF. |
|
|
|
|
|
|
|
| ▲ | CapsAdmin 8 days ago | parent | prev | next [-] |
| game math libraries often have this (and glsl gpu shader language), like "2 * vec3(1,2,3)" results in "vec3(2,4,6)" There are other cases like adding vectors to matrices and so on, but in the end this logic is defined in some custom add operator overload on a class or object in the language. (I had no idea what it meant either until i searched for examples..) |
|
| ▲ | cl3misch 8 days ago | parent | prev | next [-] |
| I wondered the same. Similarly I wish the author had provided examples for statements like > Numpy also needs to be paired with a JIT compiler to make python a real array language |
|
| ▲ | 8 days ago | parent | prev [-] |
| [deleted] |