X^y function - Kdb+ / qStudio

Home Forums Kdb+ / qStudio X^y function

Tagged: , ,

This topic contains 1 reply, has 2 voices, and was last updated by  Ryan Hamilton 5 years, 11 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
• Author
Posts
• #111266

Mikeyu4281
Member

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?

#111268

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
`

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.