cancel
Showing results for 
Search instead for 
Did you mean: 

Generating unique symbol list does not consider symbols after `p

vajindarladdad
New Contributor II

Hi Experts,

I am trying to generate symbol list of each symbol of length 1, however it does work till 16 & considers only symbol till `p but fails when length is more than 16.

L1:-16?`1; //works
asc L1 //`a`b`c`d`e`f`g`h`i`j`k`l`m`n`o`p

L1:-17?`1; //'length error

Same is the case with , when we try to create a symbol list of each symbol of length 2.

asc -256?`2 //generate symbol list with combination till ....`pp
asc -257?`2 //'length error

My question is why does it considers symbols till `p only ?

 

Thanks,

Vajindar.

 

 

 

2 REPLIES 2

mauricelim
New Contributor II

The range of generate for symbols is only from abcdefghijklmnop as documented here: https://code.kx.com/q/ref/deal/#roll-and-deal

As to why is that so, I have no idea as well. 

But you can use something like this to solve your problem:

q){[num;len] neg[num]?`${.Q.a cross x}/[len-1;enlist each .Q.a]}[17;1]
`e`n`d`g`r`y`b`p`j`l`s`i`f`k`w`u`c
q)asc{[num;len] neg[num]?`${.Q.a cross x}/[len-1;enlist each .Q.a]}[256;2]
`s#`af`an`aq`as`ax`ay`ba`bd`be`bj`bk`bl`bn`bo`bu`bw`ca`cb`cc`cd`cf`cn`co`cq`c..

 

Rolf
New Contributor III

p is the 16th letter of the alphabet.  not likely a coincidence.