Does anyone know of any functions in q that aould let me do. R^x and be able to set the values of r and x?
The caret ^ operator in kdb is used for “fills” similar to COALESCE from standard SQL. It takes the first argument and uses that value to fill in any null values on the second argument. e.g.
`
q)l:0 1 10 2 0N 22 8 0N 100
q)l
0 1 10 2 0N 22 8 0N 100
q)999^l
0 1 10 2 999 22 8 999 100
q)sl:“a`b`c“`d`e`f
q)`empty^sl
`empty`a`b`c`empty`empty`d`e`f
q)null sl
100011000b
`
To actually raise one number to the power of another in kdb we use the xexp function.
x xexp y
Raises x to the power of y. For example:
`
q)2 xexp 2
4f
q)2 xexp 3
8f
q)2 xexp 4
16f
q)2 xexp 2 3 4 5 6
4 8 16 32 64f
`