Eu tenho uma mesat
t:([] x: 1 2 3 4 5; y: 5.1 2.4 3.3 4.5 1.5);
x y
-----
1 5.1
2 2.4
3 3.3
4 4.5
5 1.5
e estou tentando redimensionar as x
linhas y
e t
de modo que a maior se torne 1 e a outra assuma o valor ceiling max(x;y)%min(x;y)
como:
rescaledUnits:{[t]
t:update l:max(x;y), s:min(x;y) from t;
t:update a:ceiling l%s, ones:1 from t;
t:update uc:ones, up:a where x>=y from t;
t:update uc:a, up:ones where x<y from t;
t
};
mas ao chamá-lo eu recebo
show rescaledUnits[t]
q)
'length
t:update a:ceiling l%s, one:1 from t;
t:update uc:one, up:a where x>=y from t;
^
t:update uc:a, up:one where x<y from t;
Como posso corrigir a função acima?
Suas declarações de atualização estão erradas
A cláusula where vem no final. As consultas Q-SQL têm a forma de
select <cols> <by> from T<exp> <where>
Você pode ler sobre isso aqui https://code.kx.com/q4m3/9_Queries_q-sql/É fácil ver que onde
x>y
o maior estáx
(e precisará se tornar1
),max(x;y)
éx
emin(x;y)
éy
. Tudo é espelhado ondex<y
: o maior estáy
(e se tornará 1),max(x;y)
éy
emin(x;y)
éx
.Portanto, não há necessidade de calcular colunas auxiliares: