Top Posts
- msum using sliding window in kdb+
- Generate all subsets of a string in q/KDB+
- Cumulative Normal Distribution in Q/KDB+
- N Queens : all possible solutions in q/kdb+
- Regular Expressions in q/KDB+
- Equality of Strings in q/KDB+
- Shorter Code to Generate all Permutations of a string in q/KDB+
- Happy Pi Day - Calculation of Pi in q/KDB+
- Generate all permutations in q/KDB+
- Learning Q KDB+
Categories
- KDB (6)
- Pricing (4)
- Q (17)
- Q Idioms (3)
- Regression (3)
- Regular Expressions (3)
- Time Series (1)
-
Join 18 other subscribers
Archives
Tag Cloud
Blog Stats
- 73,311 hits
Category Archives: Q
Matrix operations in Q/KDB+
1) Find the maximum element of each column in matrix m. max m 2) Find the minimum element of each row of a matrix m. min each x. 3) Test for symetric matrix m~flip m 4) Test for anti-symetric matrix … Continue reading
Posted in KDB, Q
Leave a comment
Alternative Solution : Q Idioms 31
x:”egg” y:”mrin” g:1 0 1 0 1 1 0 Solution Posted : (x,y)[rank g] “merging” Alternative Solution : (y,x)[iasc idesc g]
Greatest Common Divisor in Q/KDB+
Euclid’s algorithm : Recursive definition of the gcd function using Euclid’s algorithm is : function gcd(a, b) { if (b = 0) return a else return gcd(b, a mod b) } Solution in Q : g:{$[y=0;:x;:g[y;x mod y]];} Results : … Continue reading
Subvector grade down – Q Idioms 15
x:1 0 0 1 0 0 1 0 y:14 12 18 15 13 16 11 17 K solution : {,/x+’>:’x _ y}[&x;y] 2 0 1 5 3 4 7 6 Solution Posted : {raze x +’ idesc each x _ … Continue reading
Subvector grade up – QIdiom 7
x:1 0 0 1 0 0 1 0 y:14 12 18 16 13 15 11 17 Solution in K : {,/x+'<:’x _ y}[&x;y] 1 0 2 4 3 5 6 7 Solution Posted : {raze x +’ iasc each x … Continue reading
Factorial Program
Q Solution 1: factorial:{prd 1+til x} Q Solution 2: n:5 do[-1+f:r:n;r*:f-:1] r 120 The solution 2 is referred from Execution Control chapter in Q for Mortals. Results : factorial[5] 120