0

I have this:

a     b     c
"aa"  "bb"  "cc"
"aaa" "bbb" "ccc"

I want to end up with -,|,/,\ in between or any other third string:

a     b     c     ab
"aa"  "bb"  "cc"  "aa-bb"
"aaa" "bbb" "ccc" ""aaa-bbb"

for example

Thomas Smyth - Treliant
  • 4,993
  • 6
  • 25
  • 36
Alim Hasanov
  • 197
  • 1
  • 3
  • 16

1 Answers1

4
q)d:flip `a`b`c!flip 2 3#'\:"abc"
q)select ab:sv'["-";flip (a;b)] from d
ab
---------
"aa-bb"
"aaa-bbb"
q)select  "-"0:(a;b) from d
b
---------
"aa-bb"
"aaa-bbb"
Sean O'Hagan
  • 1,681
  • 8
  • 14
  • Thank you Sean. This does work, BUT there must be a simpler way. List vs. List to spit out a third list. Anyone has any other ideas? – Alim Hasanov May 03 '17 at 16:32
  • You are going to have to do something with a, and do something with b, to get "ab". The only complexity I added was to make your example tabular, but it looks like you have column headers anyway, so I suspect it's a table you are dealing with. Making it a table format will allow you to form other columns based on your reqs, e.g. "ac", but you will still need to manipulate a and c in some way to get ac. – Sean O'Hagan May 04 '17 at 08:30
  • Indeed this is what I was looking for, I just had to use "exec" instead of select because select would place the dict in the third column instead of the actual value, which "exec" does. Thanks Sean. – Alim Hasanov May 04 '17 at 09:33