Hi all.
I am curious how can I check existence of system variables (eg which placed in z,q,Q namespaces)?
that would be with \v
http://code.kx.com/wiki/Reference/Sysv
but I notice that some symbols might not be shown:
q)\v .q
,`csv
and \f
q)\f .q
aj
aj0all
andany
ascasof
attravgs
ceilingcols
corcount
covcross
cutdeltas
descdev
differdistinct
eachej
enlisteval
exceptfby
fillsfirst
fkeysflip
floorget
groupgtime
hclosehcount
hdelhopen
hsymiasc
idescij
interinv
keykeys
ljljf
loadlower
lsqltime
ltrimmavg
maxsmcount
md5mdev
medmeta
minsmmax
mminmmu
modmsum
negnext
notnull
orover
parsepeach
pjprds
prevprior
randrank
ratiosraze
read0read1
reciprocalreverse
rloadrotate
rsavertrim
savescan
setshow
signumssr
stringsublist
sumssv
systemtables
tiltrim
typeuj
ungroupunion
upperupsert
valuevar
viewviews
vswhere
wjwj1
wwxasc
xbarxcol
xcolsxdesc
xgroupxkey
xlogxprev
xrank
Please use following…
q)key `.Q
``khost
addrgc
wres
addmonthsCf
ffmt
fffl
optdef
qtv
qpV
ftord
tx`t..
q)key `.q
``negnot
nullstring
reciprocalfloor
ceilingsignum
modxbar
xlogand
or`ea..
or you can get as…
q)select from `.Q
| ::
k | 3.1
host | ![-12]
addr | ![-13]
gc | ![-20]
w | k){used
heappeak
wmaxmmap
mphysyms
symw!(.“\w”),.“\w 0”}
res | in
withinlike
binbinr
ssif
dowhile
execselect
insertupdate
..
addmonths| k){(“d”$m+y)+x-“d”$m:“m”$x}
Cf | k){x 1:0xff200000000000005700000000000000;(`$($x),“#”)1:0x}
f | k){$[^y;“”;y<0;“-”,f[x;-y];y<1;1_f[x;10+y];1e13>j:“j”$y*/x#10;(x_j..
fmt | k){$[x<#y:f[y;z];x#“*”;(-x)$y]}
ff | k){$[&/(!+y)in f:!+x;x;x,'(f_y)(#x)#0N]}
fl | k){$[98h=t:@x;+fl[+x;+y];99h=t;@[x,y;f;:;x[f]fl’y f@:&(f:!x)in!y];..
opt | k){[o]x::$[#i:&o like"-[^0-9]*";i[0]#o;o];((`$1_*:)'o)!1_'o:i_o}
q)select from `.q
| ::
neg | -:
not | ~:
null | ^:
string | $:
reciprocal| %:
floor | _:
ceiling | -_-:
signum | k){(x>0)-x<0}
mod | k){x-y*x div y}
xbar | k){x*y div x:$[16h=abs[@x];“j”$x;x]}
xlog | k){log[y]%log x}
and | &
or | |
each | k){x’y}
scan | k){x\y}
Thanks
Hemant
not work with .z:
.z.zd: (16;2;1)
key `.z
hmmm - this example does work in the .z dir:
q)\d .z
q.z)zd: (16;2;1)
q.z)\v
,`zd
and then in root:
q.z)\d .
q)eval `.z
| ::
zd| 16 2 1
.z is a faked namespace, and is not backed by a dict. This should return the contents
q)f:{raze{@[enlist[`$x]!enlist value@;`$“.z.”,x;{enlist[`]!enlist(::)}]}each string (),x}
q)fa
acb
bmc
exitf
hi
kK
ln
No
pP
pcpg
pdph
pipm
popp
pspw
qs
tsu
vsw
Wws
xz
Zt
Td
T`zd
Thanks Charles, function is useful!
typo at end of sym list?
…t
Td
T`zd might be
…t
Td
D`zd
yes, thanks
q)g:{x!@[eval;;::]each `$“.z.”,/:string x}
q)ga
bc
exitf
hi
kK
ln
No
pP
pcpg
pdph
pipm
popp
pspw
qs
ts
a | 2130706689i
b | (`symbol$())!()
c | 2i
exit| “.z.exit”
f | `
h | `sff
i | 16541i
k | 2013.04.05
K | 3f
l | (,“2”;“2015.08.01”;“2015.08.01”..
n | 0D13:25:32.043174000
..
q)h:{u:first 1?0Ng;(,x[w])!(::),d w:where not u~'d:@[eval;;u]each
$“.z.”,/:string x}
which might be equivalent to f. i feel a simplification is possible.
Attila would write
s[w]!v w:where not(::)~/{@[value;“.z.”,string x;{}]}each s
which is pretty close to yours. My mind is on other problems…
or even
q)s:a
acb
bmc
exitf
hi
kK
ln
No
pP
pcpg
pdph
pipm
popp
pspw
qs
tsu
vsw
Wws
xz
Zt
Td
T`zd
q)#[;v]where not(::)~/s!{@[value;“.z.”,string x;{}]}each s
a little shorter
q)(where not(::)~/:v)#v:s!@[value;;{}]each “.z.”,/:string s
q)where[(::)~'v]_v:s!@[value;;{}]each “.z.”,/:string s
neat, can also do
q)where[(::)~'v]_v:s!{@[value; sv
.z,x;{}]}each s
q)value .z.zd
'.z.zd
q)hasZd:not null@[value;.z.zd;{
}]
q)hasZd
0b
q).z.zd:0 2 17
q)hasZd:not null@[value;.z.zd;{
}]
q)hasZd
1b
be careful what null type you choose for returning.
q)@[{value x;1b};`.z.f;{0b}]
1b