What is the most efficient way to get pairs' array from two same sized arrays


What is the most efficient way to get pairs' array from two same sized arrays



In case if there are two arrays of the same size, like


array1: 1 2 3 4 5;
array2: 6 7 8 9 10;



What is the most efficient way to form the next array:


((1 6); (2 7); (3 8); (4 9); (5 10))




3 Answers
3




q)array1: 1 2 3 4 5;
q)array2: 6 7 8 9 10;
q)array1,'array2
1 6
2 7
3 8
4 9
5 10



q)array1: 1 2 3 4 5;
q)array2: 6 7 8 9 10;
q)array1,'array2
1 6
2 7
3 8
4 9
5 10





Thank you for help Ryan
– Anton Dovzhenko
Apr 5 '16 at 8:56





No problem. I advise going through the free kdb guides we provide (timestored.com/kdb-guides) and those on code/kx . It will give you the kdb fundamentals. Then move onto your own small projects.
– Ryan Hamilton
Apr 5 '16 at 8:59



Could also


flip (array1;array2)



If you want to pass each element of array1 & array2 to a function directly then each-both can be used :


array1


array2


each-both


q)array1: 1 2 3 4 5;
q)array2: 6 7 8 9 10;
q)f:{x,y}
q)f'[array1;array2]
(1j, 6j;2j, 7j;3j, 8j;4j, 9j;5j, 10j)






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

How to input without newline? (Python)

C++ thread error: no type named ‘type’ MINGW

Analog for TagView in flutter