File: prism-q.html

package info (click to toggle)
node-prismjs 1.30.0%2Bdfsg%2B~1.26.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,220 kB
  • sloc: javascript: 27,628; makefile: 9; sh: 7; awk: 4
file content (102 lines) | stat: -rw-r--r-- 2,166 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<h2>Comments</h2>
<pre><code>foo / This is a comment
/ This is a comment too

/
Some multi-line
comment here
\

\
This comment will
continue until the
end of code</code></pre>

<h2>Character data and strings</h2>
<pre><code>"q"
"\""
"\\"
"\142"
"foo bar baz"</code></pre>

<h2>Symbols</h2>
<pre><code>`
`q
`zaphod
`:198.162.0.2:5042
`:www.yourco.com:5042
`.new</code></pre>

<h2>Numbers</h2>
<pre><code>42
b:-123h
c:1234567890j
pi:3.14159265
float1:1f
r:1.4142e
2.0
4.00e
f:1.23456789e-10
r:1.2345678e-10e
bit:0b
byte:0x2a
a:42
bit:1b

0w 0n 0W 0Wh 0Wj</code></pre>

<h2>Dates</h2>
<pre><code>d:2006.07.04
t:09:04:59.000
dt:2006.07.04T09:04:59.000
mon:2006.07m
mm:09:04
sec:09:04:59
d:2006.07.04

0Nm 0Nd 0Nz 0Nu 0Nv 0Wd 0Wt 0Wz</code></pre>

<h2>Verbs</h2>
<pre><code>99+L
x&lt;42|x>98
(x&lt;42)|x>98
42~(4 2;(1 0))
(4 2)~(4; 2*1)</code></pre>

<h2>Adverbs</h2>
<pre><code>" ," ,/: ("Now";"is";"the";"time")
L1,/:\:L2
0+/10 20 30
(1#) each 1001 1002 1004 1003</code></pre>

<h2>Built-in functions and q-sql</h2>
<pre><code>string 42
L1 cross L2
type c
select from t where price=(max;price) fby ([]sym;ex)
ungroup `p xgroup sp
`instrument insert (`g; `$"Google"; `$"Internet")</code></pre>

<h2>Example</h2>
<pre><code>/ Example from http://code.kx.com/wiki/Cookbook/CorporateActions
getCAs:{[caTypes]
    / handles multiplie corporate actions on one date
    t:0!select factor:prd factor by date-1,sym from ca where caType in caTypes;
    t,:update date:1901.01.01,factor:1.0 from ([]sym:distinct t`sym);
    t:`date xasc t;
    t:update factor:reverse prds reverse 1 rotate factor by sym from t;
    :update `g#sym from 0!t;
  };

adjust:{[t;caTypes]
    t:0!t;
    factors:enlist 1.0^aj[`sym`date;([] date:t`date;sym:t`sym);getCAs caTypes]`factor;
    mc:c where (lower c:cols t) like "*price"; / find columns to multiply
    dc:c where lower[c] like "*size"; / find columns to divide
    :![t;();0b;(mc,dc)!((*),/:mc,\:factors),((%),/:dc,\:factors)]; / multiply or divide out the columns
  };

/ get the adjustment factors considering all corporate actions
getCAs exec distinct caType from ca

adjust[t;`dividend] / adjust trades for dividends only</code></pre>