Listing alphabets and numbers using predefined variables

When I was trying to solve Challenge#4, I was trying to remember the variables that contains string of all the alphabets such as “ABCDEFGHIJKLMNOPQRSTUVWXYZ”. After some digging, I remembered that it was .Q.A. The only reason I knew about it was because I had used it earlier at my job. If you are new to kdb, then you probably didn’t know about it. I, also, couldn’t find it on Kx reference wiki page about DotQ namespace. In fact, there are quite a few others that are not listed there but can be very handy.

My ex-boss gave me a useful command to list some handy variables in .Q namespace:

q)where[10h=type'[.Q]]#.Q
t | " bg xhijefcspmdznuvt"
A | "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
a | "abcdefghijklmnopqrstuvwxyz"
n | "0123456789"
nA| "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
<span id="yd3a1cdab25">Doctors state that controlling blood pressure is another cardiovascular disease that can affect your erectile abilities. <a href="http://cute-n-tiny.com/tag/border-collie/">sildenafil canada online</a> For men, it is their proud to use their power to meet mutual satisfaction, for women, they certainly attractive in sexual gratification. <a href="http://cute-n-tiny.com/cute-animals/dogs-in-halloween-costumes/">cialis in usa</a> Be smart and go online! In spite of being sleepless all night in his  <a href="http://cute-n-tiny.com/page/9/">cialis samples free</a> night shift duty. <a href="http://cute-n-tiny.com/cute-animals/top-10-cutest-baby-tapir-pics/">tadalafil cheapest online</a>  These phenomena exist and are called, respectively, of premature and delayed ejaculation. </span>an| &quot;abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789&quot;
b6| &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/&quot;

As you can see, .Q.A lists all the alphabets in uppercase whereas .Q.a lists them in lowercase. .Q.n is a string of all number from 0-9. .Q.nA is a combination of numbers and uppercase alphabets as well as “_”. .Q.an is a string of lowercase alphabets, uppercase alphabets and numbers. .Q.b6 is similar to .Q.an but also contains “+/”.

.Q.t is interesting. It’s not very obvious (despite my ex-boss repeatedly claiming that it is) as to what its purpose is. Not only is it a collection of random letters, there are also two spaces. If you are still scratching your head, then let me tell you the answer. It has to do with datatypes. bgxhijefcspmdznuvt are the character representation of different datatypes. For example, b is for boolean and c is for character. You can find more about them here.

That explains the letters but what about the two spaces. What’s the point of having them? Just like datatypes have character representation, they also have a numerical representation. For example, boolean is represented by b and 1. Character is represented by c and 10. You can see the numerical representation for each datatype on the link provided above. You might have noticed that there is no datatype for 0 and 3 and that is why there are spaces at those position in .Q.t. Mind = blown.

I hope you found this helpful.

Leave a comment

Your email address will not be published. Required fields are marked *