(no title)
goldenCeasar | 7 months ago
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|7 months ago
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|7 months ago
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:
npalli|6 months ago