6

I have a table T with column Sym:`IBM`MSFT`GOOG... Want the easiest way to create new column of the form newColumn: "IBM_Buy","MSFT_Buy","GOOG_Buy",...

The following does NOT seem to do the trick: select ((string Sym),"_Buy") from T

Aaron Davies
  • 1,190
  • 1
  • 11
  • 17
bigO6377
  • 1,256
  • 3
  • 14
  • 28
  • ,"_Buy" doesn't work because you're working with a vector in the select statement, not an "atom" (although in this case we're working with strings which are not atoms either!). So user1895961 answer is the correct way – Manish Patel Jun 04 '14 at 07:36

3 Answers3

9

You need to use each-left (\:). Think of it as concatenating "_Buy" to each item on a list.

select (string[Sym],\:"_Buy") from T
user1895961
  • 1,176
  • 9
  • 22
1
t:([]sym:`IBM`MSFT`GOOG)

update newsym:(string sym) cross enlist "_Buy" from t

or easy way (Dictionary Format)

t[`newsym] :
(string t[`sym]) cross enlist "_Buy"
Thomas Smyth - Treliant
  • 4,993
  • 6
  • 25
  • 36
Rahul
  • 3,914
  • 1
  • 14
  • 25
1

You may use each-both (') function with anonymous function in select statement:

select {x, "_Buy"}'[Sym] from T

G. A.
  • 25
  • 4