00001 // @file example.q 00002 // 00003 // A sample documented q source file. 00004 // 00005 // This q source file contains some example doxygen usage. 00006 // 00007 // @date 2007-01-25 00008 // 00009 00010 // Comments starting with a double slash are processed. 00011 / Comments starting with a single slash are not. 00012 00013 // a global variable 00014 x: 42 00015 00016 y: "\"}" "\\" // doc comments here are not picked up 00017 00018 00019 // Identity function 00020 f:{x} 00021 00022 // class embedded 00023 00024 // classed function 00025 .u.f: { [x] x } 00026 // classed static 00027 .u.g: 42 00028 00029 // Sometimes you see this 00030 00031 v.g: { [x] x } 00032 00033 // A class 00034 \d .t 00035 00036 // classed function 00037 f: { [x] x } 00038 // classed static 00039 g: 42 00040 00041 // a nested class with a function 00042 i.h: { [x] x } 00043 00044 \d . 00045 00046 // Simple function. Doesn't do much! 00047 // @return the value 42 00048 g:{42} 00049 00050 // Identity function. 00051 // @param x a value 00052 // @return the same value 00053 i:{[x] x} 00054 00055 // Compute the dot product of 2 arrays 00056 // @param x an array 00057 // @param y another array 00058 // @return x.y 00059 dotproduct : {[x;y] 00060 sum (x * y) 00061 } 00062 00063 // Compute the dot product of 2 arrays 00064 // @param x an array 00065 // @param y another array 00066 // @return x.y 00067 dotproductloop :{[x;y] 00068 s : "}"; 00069 l : count x; 00070 i : 0; 00071 // @remarks Very un-q like! 00072 // @note Example only. 00073 while[i < l; 00074 s : s + (x[i] * y[i]); 00075 i : i + 1 00076 ]; 00077 s 00078 } 00079 00080 // A table of trades 00081 // @arg @b time: the time the trade was made 00082 // @arg @b sym: the the stock symbol 00083 // @arg @b price: the traded price 00084 // @arg @b size: the number of units traded 00085 trade:([]time:`time$();sym:`symbol$();price:`float$();size:`int$()) 00086 00087 00088 00089 \ 00090 anything after a slash is ignored.