enlist¶
Make a list
enlist x enlist[x] enlist[x;y;z;…]
Returns a list with its arguments as items.
The most common use is to make a 1-item list.
An atom is not a 1-item list: enlist and first convert between the two.
q)a:10
q)b:enlist a
q)c:enlist b
q)type each (a;b;c)
-7 7 0h
q)a~b
0b
q)a~first b
1b
q)b~c
0b
q)b~first c
1b
The result has one item for each argument.
q)show a:enlist[til 5;`ibm`goog;"hello"]
0 1 2 3 4
`ibm`goog
"hello"
q)count a
3
Unlike user-defined functions, enlist is not limited to 8 arguments.
q)count b:enlist[0;`1;"two";3;`four;5;`6;"seven";8;`nine]
10
Where x is a dictionary, the result is a 1-item table.
q)enlist `a`b`c!(1;2 3; 4)
a b c
-------
1 2 3 4
Atoms to lists
To ensure all items in a list are themselves lists and not atoms, use (),, which leaves lists unchanged.
For example, {(),x} each foo converts any atoms in list foo into 1-item lists.
Assign a 1-item list
To assign a 1-item list to an undefined name, you can also use foo,:, which does not require foo to be defined.
q)x1:enlist[3]
q)x2,:3
q)x1~x2
1b