> IMO this is what makes something an array language.
Great to hear. So what is it?
> IMO this is what makes something an array language.
Great to hear. So what is it?
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]]]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.
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 employeeExample 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.
which shows that this feature request is complete jibberish
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.
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."
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..)
> Numpy also needs to be paired with a JIT compiler to make python a real array language