Questions tagged [k]

k is an array processing language used in the kdb+ database. Do not use this tag for general kdb questions - only for questions pertaining to code in the k language.

K is an array processing language developed by Kx Systems. It is the foundation of the database used in financial products. K draws inspiration from APL and Scheme.

78 questions
1
vote
6 answers

How to convert a symbol to a string in kdb+?

For example, if I have a list of symbols i.e (`A.ABC;`B.DEF;`C.GHI) or (`A;`B;`C), how could I convert each item in the list to a string?
abhi
  • 1,760
  • 1
  • 24
  • 40
1
vote
3 answers

Applying of projections and monadic functions in k

How to properly apply a monadic functions and projections in k? KDB+ 3.6 2018.05.17 Copyright (C) 1993-2018 Kx Systems q) \ (5*;10*)@\:2 10 20 ({x};{x*x})@\:2 2 4 (#;#)@\:2 (#[2];#[2]) Why 2 first examples work properly and the last one…
egor7
  • 4,678
  • 7
  • 31
  • 55
1
vote
1 answer

kdb q: find the C libraries it loads

I have this line of code: loadedFunc: `:mylib 2:(`myfunc;1) so from the kdb/q reference., it means loading "my func", which has one argument from the dynamic library with name mylib . Where is the path can I locate this physical library of mylib?…
CuriousMind
  • 15,168
  • 20
  • 82
  • 120
1
vote
1 answer

[kdb+/q]: Convert adjacency matrix to adjacency list

Given (rectangular) adjacency matrix m, how to construct adjacency list in q language? In QIdioms wiki I've found solution in the k language which when run through q console with k) command gives me 'vs error: m:(1 0 1;1 0 1) k) (^m)_vs…
Daniel Krizian
  • 4,586
  • 4
  • 38
  • 75
1
vote
2 answers

Adding a row to a matrix in Q?

I currently have a 3 by 3 matrix "m": 1 2 3 4 5 6 7 8 9 I would like to add a row to matrix 'm' to have a resultant matrix of: 1 2 3 4 5 6 7 8 9 10 11 12
user3387464
0
votes
2 answers

How to walkthrough tree and accumulate multiply the value of path

There is a tree: Each row is a path parent node --> child node data means the value of this path. tree:([]parent:`A`A`A`B`B`E`E;child:`B`C`D`E`F`G`H;data:(1;2;3;4;5;6;7)); My question is: For every non-leaf node (Red node in the chart), we can…
seizetheday
  • 333
  • 1
  • 6
  • 15
0
votes
2 answers

Kdb+ data fomat when writing to a file

I'm trying to understand what happen when someone try to write to a file the next way: q)h:hopen `:out q)h (1 2;3) 3i q)hclose h q)read1 `:out 0x07000200000001000000000000000200000000000000f90300000000000000 this is not the same as a binary…
egor7
  • 4,678
  • 7
  • 31
  • 55
0
votes
1 answer

Table transformation, table as list of dicts

Please help me with t1 transformation through the following path: t1:enlist `a`b!1 2; t2:exec val from ([]val:t1); -3!t1 // +`a`b!(,1;,2) -3!t2 // ,`a`b!1 2 t1~t2[;] // 1b I expect that the 2nd line (exec) returns the same object as t1, but…
egor7
  • 4,678
  • 7
  • 31
  • 55
0
votes
1 answer

Accumulator gives different result then direct function applying

Trying to combine two result sets I've faced with different behavior when joining two keyed tables: q)show t:([a:1 1 2]b:011b) a| b -| - 1| 0 1| 1 2| 1 q)t,t a| b -| - 1| 1 1| 1 2| 1 q)(,/)(t;t) a| b -| - 1| 1 2| 1 Why does the accumulator ,/…
egor7
  • 4,678
  • 7
  • 31
  • 55
0
votes
1 answer

Why does not work select from a keyed table

A query result looks good if I break keyed table apart into key-value pair and combine them together: key!value. But a straight select from it gives an error. I constructed that keyed table in a slightly weird manner: q)show t:([n:1 2] m:(`a`b!3…
egor7
  • 4,678
  • 7
  • 31
  • 55
0
votes
2 answers

FK field over IPC

Some prerequisites on the remote process: q)\p 15222 q)t:([id:10 20 30]data:`aa`bb`cc); q)kt:([]id:`t$10 20 20 30 30 30; num:til 6); and the following will be performed on a local process: The size of kt looks the same from both…
egor7
  • 4,678
  • 7
  • 31
  • 55
0
votes
1 answer

Protected execution, 2 cases

Why does in first following case protected execution work, but in second does not?: q)t:([]a:1 2;b:3 4); q)@[@[cols t; ; :; `bb]; (cols t)?`b; `columnNotFound] `a`bb q)@[@[cols t; ; :; `cc]; (cols t)?`c; `columnNotFound] // 1. works…
egor7
  • 4,678
  • 7
  • 31
  • 55
0
votes
1 answer

Select from a table with Limit expression works, without - fails

For a table t with a custom field c which is dictionary I could use select with limit expression, but simple select failes: q)r1: `n`m`k!111b; q)r2: `n`m`k!000b; q)t: ([]a:1 2; b:10 20; c:(r1; r2)); q)t a b c ---------------- 1 10 `n`m`k!111b 2 20…
egor7
  • 4,678
  • 7
  • 31
  • 55
0
votes
1 answer

Enums for tables

I found no information about what the enum is over the table domain on https://code.kx.com/q/ref/enumerate/. But something interesting exists there: https://code.kx.com/q/kb/linking-columns. I tried those examples and found an enum structure that…
egor7
  • 4,678
  • 7
  • 31
  • 55
0
votes
1 answer

Strange view declaration behaviour

In the q 3.6 32bit I see something that I can not explain. Having the same parse trees these two expressions for y1 and for y2 give way too different results: q)x:3 q)parse"y :: x*10" :: `y (*;`x;10) q)parse"y:: x*10" :: `y (*;`x;10) q)y1 ::…
egor7
  • 4,678
  • 7
  • 31
  • 55