Reputation: 5918
I have a list of strings:
q)l:("abc";"";"def";"");
How can we remove empty strings from the list l?
Desired Output:
("abc";"def")
My failed attempts:
q)l except ""
q)l except\: ""
q)l except 1#""
Upvotes: 0
Views: 1095
Reputation: 666
Using enlist on the empty string will work:
q)l except enlist""
"abc"
"def"
In many cases, 1#
and enlist
can be used interchangeably, as long as the list is not empty. Applying 1#
on an empty list will return an enlisted null of the empty list type provided:
q)1#`long$()
,0N
q)1#`symbol$()
,`
q)1#""
," "
Upvotes: 4