2021.08.30 06:53 PM
A bit at lost here... Can someone enlighten me as to how the interpreter works in the following situation:
q)show a:10?(-1 0 1) //Just to have something
0 1 1 0 -1 0 1 -1 0 0
q)(>)a //That's the curiosity
1 2 6 0 3 5 8 9 4 7
I understand this is actually the same as...
q)raze where each a=/:desc distinct a
1 2 6 0 3 5 8 9 4 7
but... can't figure out where this is coming from(!)
Thx in advance
2021.08.30 07:25 PM - edited 2021.08.30 07:27 PM
Hi JP, this is just the underlying k implementation of idesc: https://code.kx.com/q/ref/desc/#idesc
q)a:0 1 1 0 -1 0 1 -1 0 0
q)idesc
k){$[0h>@x;'`rank;>x]}
q)idesc[a]~(>)a
1b
q)\
>a
1 2 6 0 3 5 8 9 4 7
The brackets allow q to interpret this, but the use is discouraged (https://code.kx.com/q/basics/exposed-infrastructure/#unary-forms). Rather use the idesc keyword instead.
2021.08.30 07:25 PM - edited 2021.08.30 07:27 PM
Hi JP, this is just the underlying k implementation of idesc: https://code.kx.com/q/ref/desc/#idesc
q)a:0 1 1 0 -1 0 1 -1 0 0
q)idesc
k){$[0h>@x;'`rank;>x]}
q)idesc[a]~(>)a
1b
q)\
>a
1 2 6 0 3 5 8 9 4 7
The brackets allow q to interpret this, but the use is discouraged (https://code.kx.com/q/basics/exposed-infrastructure/#unary-forms). Rather use the idesc keyword instead.
2021.08.30 07:34 PM
Feel ashamed(!)... I realize I shouldn't have skipped that <k> part of the language:-)
Thx again
EMEA
Tel: +44 (0)28 3025 2242
AMERICAS
Tel: +1 (212) 447 6700
APAC
Tel: +61 (0)2 9236 5700
KX. All Rights Reserved.
KX and kdb+ are registered trademarks of KX Systems, Inc., a subsidiary of FD Technologies plc.