7 ms·
> User-Extensible Rank Polymorphism > IMO this is what makes something an array language. Great to hear. So what is it?
by abcd_f 1y ago
> User-Extensible Rank Polymorphism
> IMO this is what makes something an array language.
Great to hear. So what is it?
- preommr 1y agoNot 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 1y agoA 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 1y agoI 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 1y agoThe 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
- CraigJPerry 1y agoJust had a quick browse of the kumi readme - very cool, i like it
- goldenCeasar 1y agoThat means a lot, thanks!
- npalli 1y agoI 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 1y agoThe 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.
- almostgotcaught 1y ago> 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 1y agoWhy gibberish ? It's a common feature in both array languages and Iverson ghosts, and many find it extremely useful.
- tracker1 1y agoYou mean like a "winner" function able to check for both Tic-Tac-Toe, a Connect Four field and a Similar 3D+ tower game?
- taeric 1y agoI'm not sure I follow? The "winning" condition is different in all of those examples?
- tracker1 1y agoX 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 1y agoFair 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.
- CapsAdmin 1y agogame 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..)
- deleted 1y ago[deleted]
- cl3misch 1y agoI 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