0

I would like to add a forward slash in a field name in a table:

tab:([] yes/no:`yes`yes`no;num: 1 2 3);

I tried using `$"yes/no": but didnt work. any input?

Terry
  • 523
  • 9
  • 21
  • 2
    this would work much better as a boolean column called yes. Negates the issue of dealing with a column called yes/no and is easy to use in qSql. e.g. `select from tbl where yes` / `select from tbl where not yes` – Matt Moore Dec 19 '20 at 01:05

1 Answers1

3

Create a dictionary and use flip to create a table:

q)columns:(`$"yes/no";`num)
q)columnValues:(`yes`yes`no;1 2 3)
q)tab:flip columns!columnValues
q)tab
yes/no num
----------
yes    1
yes    2
no     3

Note that it is not good practice to name columns in this manner (you lose the ability to use qSQL) but can still access the columns by using a functional select:

q)select yes/no from tab
'/
  [0]  select yes/no from tab
                 ^
q)?[tab;();0b;enlist[`$"yes/no"]!enlist[`$"yes/no"]]
yes/no
------
yes
yes
no
jomahony
  • 1,662
  • 6
  • 9