What is the programmatic way to execute a K statement within a Qscript, i.e., the equivalent of “k) some_command” at the prompt? Maybethere isn’t one.What motivates this question is that I can’t locate the Q version of !(directory listing).
X-Mailer: Apple Mail (2.936)in a stand-alone line (i.e. outside of a function) just use the k) prefix as you would in a shellair:~ :) % cat foo.qk)!.qair:~ :) % q foo.qKDB+ 2.6 2009.09.15 Copyright (C) 1993-2009 Kx Systemsm32/ 2()core 2048MB
neg
not null
stringreciprocal
floorceiling
signummod
xbarxlog
andor
ea..functions, afaik, have to be either in k or q, they can’t be mixed; however, you can always eval strings of either languageq){get"k)!.q"}[]
neg
not null
stringreciprocal
floorceiling
signummod
xbarxlog
andor
ea..in any case, monadic ! is always and exactly “key” in qq)key.q
neg
not null
stringreciprocal
floorceiling
signummod
xbarxlog
andor
ea..q)key!:On Sep 18, 2009, at 7:40 AM, annakh7 wrote:> What is the programmatic way to execute a K statement within a Q> script, i.e., the equivalent of “k) some_command” at the prompt? Maybe> there isn’t one.>> What motivates this question is that I can’t locate the Q version of !> (directory listing).
Thanks. What I was looking for is a way to write files: k) !dirwhich in this form doesn’t work. Is eval the only solution?
X-Mailer: Apple Mail (2.936)> Thanks. What I was looking for is a way to write>> files: k) !dir>> which in this form doesn’t work. Is eval the only solution?the k) goes before the whole statementk)files:!dir
> the k) goes before the whole statementOf course. Silly me. Thanks again
To: personal-kdbplus@googlegroups.comX-Mailer: Apple Mail (2.1076)On 18.09.2009, at 01:40, annakh7 wrote:> What motivates this question is that I can’t locate the Q version of !> (directory listing).https://code.kx.com/trac/wiki/Reference/key
Yes but “key” as a directory lister is not intuitive. I have theFunction Reference bookmarked but sometimes you look at all the verbnames and nothing rings a bell…
On Fri, Sep 18, 2009 at 5:48 PM, annakh7 <annakh7@googlemail.com> wrote:
Yes but “key” as a directory lister is not intuitive. I have the
Function Reference bookmarked but sometimes you look at all the verb
names and nothing rings a bell…
As opposed to ! which only has four different uses in K. Very intuitive indeed :)
–
Hey! It compiles! Ship it!
X-Mailer: Apple Mail (2.936)> Yes but “key” as a directory lister is not intuitive. I have the> Function Reference bookmarked but sometimes you look at all the verb> names and nothing rings a bell…you think that’s bad, check out “get”
Allright, K, with its heavily overloaded glyphs, isn’t intuitive: whatcan I say, I like it nonetheless, but Q is supposed to be. Since Quses plain english names there was no need to carry over into Q theoverloading typical of K: different uses of the same glyph could havebeen christened differently.
Date: Sat, 19 Sep 2009 10:58:06 -0400Message-ID: <32bf96e80909190758t462f4958od788e183bb004255@mail.gmail.com>Subject: Re: [personal kdb+] Re: K modeFrom: Tim Rieder To: “personal-kdbplus@googlegroups.com” I like to think of directories as dictionaries (kdb does the same withnamespaces) where the keys are the file names and their values are thecontents of the files.get is only “confusing” when you use it for something other thanresolving a value from a symbol/handle as in what you would normallyuse value for i.e. get"1+1". Was that what you had in mind?On Sep 18, 2009, at 1:28 PM, Aaron Davies <aaron.davies>wrote:>>> Yes but “key” as a directory lister is not intuitive. I have the>> Function Reference bookmarked but sometimes you look at all the verb>> names and nothing rings a bell…>> you think that’s bad, check out “get”>> ></aaron.davies>
X-Mailer: Apple Mail (2.936)> get is only “confusing” when you use it for something other than> resolving a value from a symbol/handle as in what you would normally> use value for i.e. get"1+1". Was that what you had in mind?just off the top of my head, get isevaluate string code (get"1+1")evaluate parsed code (get(+;1;1))dereference a global (f:1;getf)load data from disk (save
f;get:f)return the key side of a dictionary (get
a`b!1 2)and there’s probably at least one or two i’m forgetting. it’s not confusing exactly, just a bit overloaded.
Agreed. Don’t forget apply and dyadic protected execution.
X-Mailer: Apple Mail (2.936)i was sticking strictly to monadic dot. apply is two-, three-, or four- argument, and try is always three.On Sep 20, 2009, at 10:48 PM, Tim Rieder wrote:> Agreed. Don’t forget apply and dyadic protected execution.>> On Sun, Sep 20, 2009 at 9:14 AM, Aaron Davies > <aaron.davies> wrote:>> > get is only “confusing” when you use it for something other than> > resolving a value from a symbol/handle as in what you would normally> > use value for i.e. get"1+1". Was that what you had in mind?>> just off the top of my head, get is>> evaluate string code (get"1+1")>> evaluate parsed code (get(+;1;1))>> dereference a global (f:1;getf)>> load data from disk (save
f;get:f)>> return the key side of a dictionary (get
a`b!1 2)>> and there’s probably at least one or two i’m forgetting. it’s not> confusing exactly, just a bit overloaded.</aaron.davies>