Showing results for 
Search instead for 
Did you mean: 
Valued Contributor
Valued Contributor

We encounter the enlist keyword early in learning q; a reliable way to make a one-item list where 1# won’t do. But there is a bit more to enlist than that.

In the first place, it is not only variadic – taking various numbers of arguments – it will take any number of arguments, even more than eight.






Of course, what it returns is a list, with each argument an item.





What is less obvious is that enlist is implicated in lists with missing items.


q)type (`one;`two;`three)  / symbol vector
q)type (`one;::;`three)  / mixed list
q)type (`one;;`three)  / a -- projection?
q)(`one;;`three) ~ enlist[`one;;`three]


Is the missing item a generic null? No, a list with one or more missing items is a projection of enlist, and its rank is the number of missing arguments. We can apply and iterate it as any other projection.


q)(`one;;`three;;`five) . `two`four
q)raze `quick`crafty`cunning(`the;;`brown;;`jumps)/:\:`fox`cat`dog
the quick   brown fox jumps
the quick   brown cat jumps
the quick   brown dog jumps
the crafty  brown fox jumps
the crafty  brown cat jumps
the crafty  brown dog jumps
the cunning brown fox jumps
the cunning brown cat jumps
the cunning brown dog jumps


Which gives us a few tricks up our sleeves when generating test datasets, or preparing data for loading and ingestion.

1 Comment
Moderator Moderator

Thank you very much for sharing @SJT

Great q-bie content here 👏