capser
capser

Reputation: 2635

KDB show table, not cumulative results

In the tutorial on kdb: https://code.kx.com/q4m3/1_Q_Shock_and_Awe/ It deals with a FIFO allocation

The tutorial calls for the user to assign the lists respectively:

q)buys:2 1 4 3 5 4f
q)sell:12f

The tutorial show the answer as this:

q)deltas each deltas sums[sells] &\: sums[buys]
2 0 0 0 0 0
0 1 3 0 0 0
0 0 1 2 0 0
0 0 0 1 1 0

however when i run the smae line in q, I get the following.

q)deltas each deltas sums[sells] &\: sums[buys]
2 1 4 3 2 0f
q)

i understand the results, however i want to display them in a table graphically as is is show in the tutorial.I want to see the table, spanned over four rows, as opposed the the cumulative answer in one line.

Upvotes: 0

Views: 131

Answers (1)

jomahony
jomahony

Reputation: 1692

The tutorial has sells defined differently:

q)buys:2 1 4 3 5 4f
q)sells:2 4 3 2
q)deltas sums[sells] &\: sums[buys]
2 2 2 2 2 2
0 1 4 4 4 4
0 0 1 3 3 3
0 0 0 1 2 2
q)deltas each deltas sums[sells] &\: sums[buys]
2 0 0 0 0 0
0 1 3 0 0 0
0 0 1 2 0 0
0 0 0 1 1 0

Upvotes: 1

Related Questions