https://learninghub.kx.com/forums/topic/fundamentals-capstone-4-3
Hi I have been trying on it but I am not sure what mistake I made on the code
returnN: {[orderCol;order;N;t] $[order=`top;N# orderCol xasc t;(neg N) # orderCol xasc t]} returnN [`qty;`top;5;edge15]
Any ideas would be nice thanks!
Hi !
Have you had a look at the template for returnN ?
I think a key feature that you could use is sublist - Sublist of a list | Reference | kdb+ and q documentation - Kdb+ and q documentation (kx.com)
So simply order the table by the column provided in ascending order then subset the first/last N records from the newly ordered table.
If you are still unsure, please feel free to reach out.
Many thanks,
Megan
Looking at the test cases, it seems expected values are wrongly set up.
While the exercise asks for top 5 values in ascending order, it expects last 5 values in result and vice versa for 2nd test case.
test.tab:-10?([]col: til 10);
test.top5col:([]col:5 6 7 8 9);
test.bottom6:([]col: til 6);