list as map

I’m a newbie, just started with Q. Sorry if it’s silly question.

JB’s Q4Mortals – quoting from it.

“From the perspective of list as map, the fact that indexing outside the bounds of a list returns null means the map is implicitly extended to the domain of all integers with null values outside the list items.”

Can you please clarify what “domain of all integers with null values outside the list items”? Is it just mean the limit or anything else?


Thanks!

q)list

1 2 3 4

q)list[3]

4

q)list[4]

0N

q)list[4000000000000000000]

0N

q)list[40000000000000000000]

'40000000000000000000

Your error means the “number” cannot be interpreted - that’s how I read it, there is no specific error definition for it. 

The largest integer type is of long - 

q)(`long$2 xexp 64)-1

9223372036854775806

q)0W-1

9223372036854775806

http://www.kx.com/q/d/a/kdb+1.htm#Integer Arithmetic

What happens when I try to index using these numbers?

q)list 9223372036854775806

0N

q)list 9223372036854775807

0N

q)list 9223372036854775808

'9223372036854775808

Your 400…000 number is too big and hence your error.

if you index into a list “outside of the list items” you will get null.

if you index into the list inside of the list items you will get the values you require. 

Hope this clears it up…(not a very good explanation on my part, perhaps someone will give you more clarity)

Sean

On Monday, February 23, 2015 at 10:11:27 AM UTC-5, Sangam G. wrote:

q)list[40000000000000000000]

'40000000000000000000

This error has nothing to do with “list” or indexing.   40000000000000000000 is simply not a valid number in q (it is too big):

q)40000000000000000000

'40000000000000000000

to beat this horse to death…

40000000000000000000 is too big as a 64bit signed int literal.

Of course, it’s not too big if you specify as float literal

q)40000000000000000000f

4e+19

(however floats are an inappropriate type for keys).