Random question about ?

Received: by 10.100.120.6 with SMTP id s6mr56223anc.24.1221895755464; Sat, 20 Sep 2008 00:29:15 -0700 (PDT)Date: Sat, 20 Sep 2008 00:29:15 -0700 (PDT)X-IP: 66.92.3.193User-Agent: G2/1.0X-Google-Token: PGOJiwwAAAAy7e90xqzGRr-SZtT1kn3YX-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_5; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1,gzip(gfe),gzip(gfe)Message-ID: <9f30ff3b-e5c4-480f-86d0-fa30887c4a7b@b38g2000prf.googlegroups.com>Subject: Random question about ?From: tildeleb To: “Kdb+ Personal Developers” X-Google-Approved: charles.g.skelton@googlemail.com via email at 2008-09-20 07:31:07I’m (very) new to kdb and q.1. Why does “2?2” produce something like:0 1and"1?2" produce:,0I am confused by the leading comma. Is it a join operator or is the"," part of lexical syntax of numbers, or something else?2. Can someone confirm that “rand” and “find” both are named “?” andthe function is overloaded based on the left and right argument types?3. Is the definition of “?” in the file “q.k” or is it builtin?Thanks in advance.leb

X-Mailer: Apple Mail (2.926)1. read it “2 random integers up to value 2” 1?2 is just one random number. the leading comma is a marker of a vector with a single element which is different from the atom 0.2. yes. the function is overloaded.3. it is a built-in.felixOn 20 Sep 2008, at 10:29, tildeleb wrote:>> I’m (very) new to kdb and q.>> 1. Why does “2?2” produce something like:> 0 1>> and>> “1?2” produce:> ,0>> I am confused by the leading comma. Is it a join operator or is the> “,” part of lexical syntax of numbers, or something else?>> 2. Can someone confirm that “rand” and “find” both are named “?” and> the function is overloaded based on the left and right argument types?>> 3. Is the definition of “?” in the file “q.k” or is it builtin?>> Thanks in advance.>> leb>>>> >

This page has a quick summary of the main operators, several of which are overloaded -
  https://code.kx.com/trac/wiki/Reference
  [with user=anonymous pass=anonymous to access the page]

gord.

On Sat, Sep 20, 2008 at 3:29 PM, tildeleb wrote:> “1?2” produce:> ,0>> I am confused by the leading comma. Is it a join operator or is the> “,” part of lexical syntax of numbers, or something else?certain results are printed in a k4 data format, not a q formatin k4, “,”, interpreted monadically, is the same as the q function"enlist"–it makes a list out of its argumentso “,0” is the integer list with one element, a 0(join is dyadic comma; generally, k4 monadic punctuation becomesenglish words in q, while dyadics punctuation stays as-is)note that the current method of printing results to the consolesometimes strips leading commas (i don’t know why)for an unambiguous result, i suggest putting the following line in your q.q:.q.unshow:{-1@-3!x;}then “unshow” is a function that prints the full k4 representation ofits argument> 3. Is the definition of “?” in the file “q.k” or is it builtin?builtins can be easily recognized: any function or punctuation which,when you enter it by itself as a command, returns itself, is abuiltin. anything else is defined somewhere (q.k or your own code)q)++q),q)sumsumq)sums+-- Aaron Daviesaaron.davies@gmail.com