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
92
votes
7 answers

APL versus A versus J versus K?

The array-language landscape, while fascinating, is confusing to no end. Is there a reason to pick one of J or K or APL or A? None of these options seem to be open-sourced -- are there open sourced versions? I would love the expand my mind, but I…
fogus
  • 6,126
  • 5
  • 36
  • 42
15
votes
2 answers

Are there any open source projects written in APL?

I'm trying to learn APL (Kona), and I'm looking for example projects so I can get an understanding of how an experienced APL'er would organize his/her code. Any open source projects would be helpful but, non-financial or anything lacking heavy math…
jdeseno
  • 7,753
  • 1
  • 36
  • 34
9
votes
2 answers

K/APL style programming in C++?

I'm writing code in C++, but I really like K/APL's array-oriented style. Does anyone know of a good set of operator overloading tricks / macros / ... to allow some K/APL -style programming in C++? Thanks!
anon
  • 41,035
  • 53
  • 197
  • 293
8
votes
6 answers

Learning J/K/APL

I know all 3 are related, and I've seen quite a few answers for problems in Project Euler written in J, and a few written K. What I'm wondering is, which would you suggest learning, and where would you suggest going about getting the materials to…
Ashton K
  • 875
  • 1
  • 8
  • 18
8
votes
4 answers

Keeping your code in L1 cache

I have been reading Wikipedia's article on K programming language and this is what I saw: The small size of the interpreter and compact syntax of the language makes it possible for K applications to fit entirely within the level 1 cache of the…
pitr
  • 715
  • 1
  • 8
  • 25
5
votes
1 answer

K pattern for iterator protocol

I'm playing with John Earnest's K implementation in the context of Project Euler problems. Many of the problems involve taking the first n terms, or all terms <= n, from an infinite series (particularly primes). It could also involve taking items…
chrispsn
  • 243
  • 1
  • 4
5
votes
1 answer

KDB reverse asof join (aj) ie on next quote instead of previous one

aj[`time`sym;trade;quote] is joining each trade with the previous value of quote. I'd like to do the same join, but on the next value of quote instead of the previous one. How can I achieve this?
Sithered
  • 481
  • 7
  • 23
5
votes
4 answers

Core of APL, J, K

I'm trying to understand APL, J, K, and it's slightly frustrating since: Most books seen to be about APL, but few APL implementations, and I don't have weird keyboards. K appears to have been replaced by Q J doesn't seem to have I almost feel like…
user1311390
4
votes
2 answers

KDB+/Q: About unused parameters in inner functions

I have this function f f:{{z+x*y}[x]/[y]} I am able to call f without a 3rd parameter and I get that, but how is the inner {z+x*y} able to complete without a third parameter?
zrb
  • 851
  • 7
  • 16
4
votes
1 answer

KDB/k: Functional form to create a table variable

Is there a functional form equivalent to the following? trades:([]date:`date$();time:`time$();sym:`symbol$();price:`real$();size:`int$(); cond:`char$()) Assuming the function name is "ct"... trades:ct[fieldNames;types]
zrb
  • 851
  • 7
  • 16
3
votes
3 answers

How can express this imperative function in a functional, array-based language like K (or Q)?

How can express this imperative function in a functional, array-based language like K (or Q)? In sloppy C++: vector x(10), y(10); // Assume these are initialized with some values. // BTW, 4 is just a const -- it's part of the algorithm and is…
Badmanchild
  • 990
  • 9
  • 18
3
votes
3 answers

Size of a table (in bytes) in Q

How can I read the size of a table (in bytes) in Q? I know that hcount returns the size of a file in bytes, but I can't find something similar for tables (or in general any object...)
Chris Taylor
  • 46,912
  • 15
  • 110
  • 154
3
votes
3 answers

Pascal's triangle in k/q

fibonacci is nice: f:|+\ 5 f\1 1 but i haven't found a similar expression for Pascal's Triangle. this is the best i can get: q){x+\\x#1}6 1 1 1 1 1 1 1 2 3 4 5 6 1 3 6 10 15 21 1 4 10 20 35 56 1 5 15 35 70 126 1 6 21 56 126…
effbiae
  • 1,087
  • 1
  • 7
  • 22
2
votes
1 answer

.Q.trp and bt handling

I saw (in .Q.fpn) the following technique to parse and show the bt object passed to .Q.trp function: q)f:{x+1} q).Q.trp[f;`a;{'(x;y)}] 'type [4] f:{x+1} ^ [3] (.Q.trp) [2] .Q.trp[f;`a;{'(x;y)}] ^ [0] …
egor7
  • 4,678
  • 7
  • 31
  • 55
2
votes
1 answer

How to count each list length in K?

On a page https://shakti.com/tutorial/ I've found the solution, it is #:'z / counts each list The same solution was mentioned in https://code.kx.com/v2/learn/startingkdb/language/ by switching to k mode in q: q) #:'(1 2;"abc") /…
egor7
  • 4,678
  • 7
  • 31
  • 55
1
2 3 4 5 6