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 00011 // Comments starting with a double slash are processed. 00012 / Comments starting with a single slash are not. 00013 00014 // a global variable 00015 x: 42 00016 00017 y: "\"}" "\\" // doc comments here are not picked up 00018 00019 00020 // Identity function 00021 f:{x} 00022 00023 // Simple function. Doesn't do much! 00024 // @return the value 42 00025 g:{42} 00026 00027 // Identity function. 00028 // @param x a value 00029 // @return the same value 00030 i:{[x] x} 00031 00032 // Compute the dot product of 2 arrays 00033 // @param x an array 00034 // @param y another array 00035 // @return x.y 00036 dotproduct : {[x;y] 00037 sum (x * y) 00038 } 00039 00040 // Compute the dot product of 2 arrays 00041 // @param x an array 00042 // @param y another array 00043 // @return x.y 00044 dotproductloop :{[x;y] 00045 s : "}"; 00046 l : count x; 00047 i : 0; 00048 // @remarks Very un-q like! 00049 // @note Example only. 00050 while[i < l; 00051 s : s + (x[i] * y[i]); 00052 i : i + 1 00053 ]; 00054 s 00055 } 00056 00057 // A table of trades 00058 // @arg @b time: the time the trade was made 00059 // @arg @b sym: the the stock symbol 00060 // @arg @b price: the traded price 00061 // @arg @b size: the number of units traded 00062 trade:([]time:`time$();sym:`symbol$();price:`float$();size:`int$()) 00063 00064 00065 00066 \ 00067 anything after a slash is ignored.