Initial commit of newLISP.
[newlisp.git] / primes.h
blob1ac3350ebf5284f379b1f3d19475af9d087aa767
1 /* primes.h - table of primitives
3 Copyright (C) 2008 Lutz Mueller
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 PRIMITIVE primitive[] =
23 /* --------- core ------------------ */
24 #ifdef SYMBOL_DEBUG
25 {"dump-symbol", p_dumpSymbol, 0},
26 #endif
27 {"while", p_while, 2},
28 {"until", p_until, 2},
29 {"do-while", p_doWhile, 2},
30 {"do-until", p_doUntil, 2},
31 {"dotimes", p_dotimes, 2},
32 {"for", p_for, 2},
33 {"sequence", p_sequence, 0},
34 {"series", p_series, 0},
35 {"doargs", p_doargs, 2},
36 {"dolist", p_dolist, 2},
37 {"dostring", p_dostring, 2},
38 {"dotree", p_dotree, 2},
39 {"case", p_case, 2},
40 {"cond", p_condition,1},
41 {"begin", p_evalBlock,1},
42 {"and", p_and, 0},
43 {"if", p_if, 2},
44 {"when", p_when, 2},
45 {"unless", p_unless, 2},
46 {"or", p_or, 0},
47 {"quote", p_quote, 0},
48 {"silent", p_silent, 0},
49 {"eval", p_eval, 0},
50 {"amb", p_amb, 0},
51 {"catch", p_catch, 0},
52 {"throw", p_throw, 0},
53 {"apply", p_apply, 0},
54 {"curry", p_curry, 0},
55 {"args", p_args, 0},
56 {"map", p_map, 0},
57 {"name", p_name, 0},
58 {"filter", p_filter, 0},
59 {"clean", p_clean, 0},
60 {"index", p_index, 0},
61 {"define", p_define, 2},
62 {"define-macro", p_defineMacro, 2},
63 {"expand", p_expand, 0},
64 {"constant", p_constant, 0},
65 {"global", p_global, 0},
66 {"set", p_set, 0},
67 {"setq", p_setq, 0},
68 {"let", p_let, 2},
69 {"local", p_local, 2},
70 {"letn", p_letn, 2},
71 {"letex", p_letExpand,3},
72 {"first", p_first, 0},
73 {"flat", p_flat, 0},
74 {"last", p_last, 0},
75 {"rest", p_rest, 0},
76 {"cons", p_cons, 0},
77 {"append", p_append, 0},
78 {"list", p_list, 0},
79 {"nth", p_nth, 0},
80 {"nth-set", p_nthSet, 0},
81 {"ref", p_ref, 0},
82 {"set-ref", p_setRef, 0},
83 {"ref-set", p_refSet, 0},
84 {"ref-all", p_refAll, 0},
85 {"set-ref-all", p_setRefAll,0},
86 {"select", p_select, 0},
87 {"swap", p_swap, 0},
88 {"slice", p_slice, 0},
89 {"length", p_length, 0},
90 {"find", p_find, 0},
91 {"search", p_search, 0},
92 {"member", p_member, 0},
93 {"intersect", p_intersect, 0},
94 {"difference", p_difference, 0},
95 {"unique", p_unique, 0},
96 {"assoc", p_assoc, 0},
97 {"lookup", p_lookup, 0},
98 {"count", p_count, 0},
99 {"set-assoc", p_setAssoc, 0},
100 {"assoc-set", p_assocSet, 0},
101 {"replace-assoc", p_replaceAssoc, 0},
102 {"pop-assoc", p_popAssoc, 0},
103 {"set-nth", p_setNth, 0},
104 {"replace", p_replace, 0},
105 {"sort", p_sort, 0},
106 {"push", p_push, 0},
107 {"pop", p_pop, 0},
108 {"reverse", p_reverse, 0},
109 {"rotate", p_rotate, 0},
110 {"dup", p_dup, 0},
111 {"not", p_not, 0},
112 {"+", p_add, 0},
113 {"-", p_subtract, 0},
114 {"*", p_multiply, 0},
115 {"/", p_divide, 0},
116 {"%", p_modulo, 0},
117 {"<", p_less, 0},
118 {">", p_greater, 0},
119 {"<=", p_lessEqual,0},
120 {">=", p_greaterEqual,0},
121 {"=", p_equal, 0},
122 {"!=", p_notEqual, 0},
124 /* --------- bit ops --------------- */
125 {"<<", p_shiftLeft,0},
126 {">>", p_shiftRight, 0},
127 {"&", p_bitAnd, 0},
128 {"|", p_bitOr, 0},
129 {"^", p_bitXor, 0},
130 {"~", p_bitNot, 0},
132 /* --------- math and float ------- */
133 {"inc", p_increment, 0},
134 {"dec", p_decrement, 0},
135 {"add", p_addFloat, 0},
136 {"sub", p_subFloat, 0},
137 {"mul", p_mulFloat, 0},
138 {"div", p_divFloat, 0},
139 {"abs", p_abs, 0},
140 {"ceil", p_ceil, 0},
141 {"floor", p_floor, 0},
142 {"erf", p_erf, 0},
143 {"sgn", p_sgn, 0},
144 {"sin", p_sin, 0},
145 {"cos", p_cos, 0},
146 {"tan", p_tan, 0},
147 {"asin", p_asin, 0},
148 {"acos", p_acos, 0},
149 {"atan", p_atan, 0},
150 {"atan2", p_atan2, 0},
151 {"sinh", p_sinh, 0},
152 {"cosh", p_cosh, 0},
153 {"tanh", p_tanh, 0},
154 {"asinh", p_asinh, 0},
155 {"acosh", p_acosh, 0},
156 {"atanh", p_atanh, 0},
157 {"round", p_round, 0},
158 {"exp", p_exp, 0},
159 {"log", p_log, 0},
160 {"sqrt", p_sqrt, 0},
161 {"rand", p_rand, 0},
162 {"seed", p_seed, 0},
163 {"random", p_random, 0},
164 {"normal", p_normal, 0},
165 {"randomize", p_randomize,0},
166 {"encrypt", p_encrypt, 0},
167 {"min", p_minFloat, 0},
168 {"max", p_maxFloat, 0},
169 {"pow", p_powFloat, 0},
170 {"mod", p_modFloat, 0},
171 {"prob-z", p_probabilityZ, 0},
172 {"prob-chi2", p_probabilityChi2, 0},
173 {"crit-chi2", p_criticalChi2, 0},
174 {"crit-z", p_criticalZ, 0},
175 {"fft", p_fft, 0},
176 {"ifft", p_ifft, 0},
177 {"beta", p_beta, 0},
178 {"betai", p_betai, 0},
179 {"gammaln", p_gammaln, 0},
180 {"gammai", p_gammai, 0},
181 {"binomial", p_binomial, 0},
182 {"factor", p_factor, 0},
183 {"pmt", p_pmt, 0},
184 {"pv", p_pv, 0},
185 {"fv", p_fv, 0},
186 {"nper", p_nper, 0},
187 {"npv", p_npv, 0},
188 {"irr", p_irr, 0},
189 {"transpose", p_matTranspose, 0},
190 {"multiply", p_matMultiply, 0},
191 {"invert", p_matInvert, 0},
192 {"det", p_determinant, 0},
193 {"mat", p_matScalar, 0},
194 {"array", p_array, 0},
195 {"array-list", p_arrayList, 0},
196 {"flt", p_flt, 0},
197 {"bayes-train", p_bayesTrain, 0},
198 {"bayes-query", p_bayesQuery, 0},
199 {"unify", p_unify, 0},
200 {"bind", p_bind, 0},
201 {"uuid", p_uuid, 0},
202 {"gcd", p_gcd, 0},
204 /* ------------ string ops ------------- */
205 {"eval-string", p_evalString, 0},
206 {"join", p_join, 0},
207 {"chop", p_chop, 0},
208 {"explode", p_explode, 0},
209 {"trim", p_trim, 0},
210 {"char", p_char, 0},
211 {"starts-with", p_startsWith, 0},
212 {"ends-with", p_endsWith, 0},
213 {"upper-case", p_upper, 0},
214 {"lower-case", p_lower, 0},
215 {"title-case", p_title, 0},
216 {"format", p_format, 0},
217 {"match", p_match, 0},
218 {"regex", p_regex, 0},
219 {"int", p_integer, 0},
220 {"integer", p_integer, 0},
221 {"float", p_float, 0},
222 {"sym", p_symbol, 0},
223 {"string", p_string, 0},
224 {"get-float", p_getFloat, 0},
225 {"get-string", p_getString, 0},
226 {"get-int", p_getInteger, 0},
227 {"get-long", p_getLong, 0},
228 {"get-char", p_getChar, 0},
229 {"parse", p_parse, 0},
230 #ifndef WIN_32
231 {"parse-date", p_parseDate, 0},
232 #endif
233 {"pack", p_pack, 0},
234 {"unpack", p_unpack, 0},
235 {"xml-parse", p_XMLparse, 0},
236 {"xml-error", p_XMLerror, 0},
237 {"xml-type-tags", p_XMLtypeTags, 0},
238 {"base64-enc", p_base64Enc, 0},
239 {"base64-dec", p_base64Dec, 0},
240 {"crc32", p_crc32, 0},
241 {"find-all", p_findAll, 0},
242 #ifdef SUPPORT_UTF8
243 {"unicode", p_unicode, 0},
244 {"utf8", p_utf8, 0},
245 {"utf8len", p_utf8len, 0},
246 #endif
248 /* -------------- I/O ------------------ */
249 {"command-line", p_commandLine, 0},
250 {"pretty-print", p_prettyPrint, 0},
251 {"print", p_print, 0},
252 {"println", p_println, 0},
253 {"read-line", p_readLine, 0},
254 {"write-line", p_writeLine, 0},
255 {"current-line",p_currentLine,0},
256 {"device", p_device, 0},
257 {"load", p_load, 0},
258 {"save", p_save, 0},
259 {"source", p_symbolSource, 0},
260 {"open", p_open, 0},
261 {"close", p_close, 0},
262 {"read-char", p_readChar, 0},
263 {"write-char", p_writeChar,0},
264 {"read-buffer", p_readBuffer,0},
265 {"write-buffer",p_writeBuffer,0},
266 {"write-file", p_writeFile,0},
267 {"append-file", p_appendFile, 0},
268 {"read-file", p_readFile, 0},
269 {"read-key", p_readKey, 0},
270 {"get-url", p_getUrl, 0},
271 {"put-url", p_putUrl, 0},
272 {"post-url", p_postUrl, 0},
273 {"delete-url", p_deleteUrl,0},
274 {"destroy", p_destroyProcess, 0},
275 {"exec", p_exec, 0},
276 {"process", p_process, 0},
277 {"pipe", p_pipe, 0},
278 #ifndef WIN_32
279 {"fork", p_fork, 0},
280 {"wait-pid", p_waitpid, 0},
281 #endif
282 #ifndef OS2
283 {"share", p_share, 0},
284 #endif
285 {"semaphore", p_semaphore,0},
286 {"seek", p_seek, 0},
287 #ifndef WIN_32
288 {"peek", p_peek, 0},
289 #endif
291 /* --------- system/predicates --------- */
292 {"set-locale", p_setlocale, 0},
293 {"for-all", p_forAll, 0},
294 {"exists", p_exists, 0},
295 {"nil?", p_isNil, 0},
296 {"true?", p_isTrue, 0},
297 {"NaN?", p_isnan, 0},
298 {"integer?", p_isInteger, 0},
299 {"float?", p_isFloat, 0},
300 {"number?", p_isNumber, 0},
301 {"string?", p_isString, 0},
302 {"symbol?", p_isSymbol, 0},
303 {"legal?", p_isLegal, 0},
304 {"context?", p_isContext, 0},
305 {"primitive?", p_isPrimitive, 0},
306 {"atom?", p_isAtom, 0},
307 {"quote?", p_isQuote, 0},
308 {"list?", p_isList, 0},
309 {"lambda?", p_isLambda, 0},
310 {"macro?", p_isMacro, 0},
311 {"array?", p_isArray, 0},
312 {"empty?", p_isEmpty, 0},
313 {"null?", p_isNull, 0},
314 {"zero?", p_isZero, 0},
315 {"file?", p_isFile, 0},
316 {"directory?", p_isDirectory, 0},
317 {"global?", p_isGlobal, 0},
318 {"protected?", p_isProtected, 0},
319 {"symbols", p_symbols, 0},
320 {"exit", p_exit, 0},
321 {"debug", p_debug, 0},
322 {"trace", p_trace, 0},
323 {"trace-highlight", p_traceHighlight,0},
324 {"reset", p_reset, 0},
325 {"throw-error", p_throwError, 0},
326 {"error-event", p_errorEvent, 0},
327 {"error-number",p_errorNumber,0},
328 {"error-text", p_errorText, 0},
329 {"signal", p_signal, 0},
330 {"sys-info", p_systemInfo, 0},
331 {"sys-error", p_systemError, 0},
332 {"date", p_date, 0},
333 {"!", p_system, 0},
334 {"file-info", p_fileInfo, 0},
335 {"copy-file", p_copyFile, 0},
336 {"rename-file", p_renameFile, 0},
337 {"delete-file", p_deleteFile, 0},
338 {"make-dir", p_makeDir, 0},
339 {"remove-dir", p_removeDir, 0},
340 {"change-dir", p_changeDir, 0},
341 {"directory", p_directory, 0},
342 {"real-path", p_realpath, 0},
343 {"main-args", p_mainArgs, 0},
344 {"env", p_env, 0},
345 {"context", p_context, 0},
346 {":", p_colon, 0},
347 {"default", p_default, 0},
348 {"timer", p_timerEvent, 0},
349 #ifndef NOIMPORT
350 {"import", p_importLib, 0},
351 {"callback", p_callback, 0},
352 #endif
353 {"delete", p_deleteSymbol, 0},
354 {"new", p_new, 0},
355 {"def-new", p_defineNew, 0},
356 {"address", p_address, 0},
357 {"dump", p_dump, 0},
358 {"cpymem", p_copyMemory, 0},
359 {"sleep", p_sleep, 0},
360 {"time", p_time, 0},
361 {"time-of-day", p_timeOfDay, 0},
362 {"now", p_now, 0},
363 {"date-value", p_dateValue, 0},
364 {"$", p_systemSymbol, 0},
366 /* ------------ net working ------------ */
367 {"net-close", p_netClose, 0},
368 {"net-service", p_netService, 0},
369 {"net-connect", p_netConnect, 0},
370 {"net-accept", p_netAccept, 0},
371 {"net-local", p_netLocal, 0},
372 {"net-peer", p_netPeer, 0},
373 {"net-lookup", p_netLookup, 0},
374 {"net-receive", p_netReceive, 0},
375 {"net-receive-from",p_netReceiveFrom,0},
376 {"net-receive-udp", p_netReceiveUDP,0},
377 {"net-send", p_netSend, 0},
378 {"net-send-to", p_netSendTo, 0},
379 {"net-send-udp", p_netSendUDP, 0},
380 {"net-listen", p_netListen, 0},
381 {"net-peek", p_netPeek, 0},
382 {"net-select", p_netSelect, 0},
383 {"net-sessions", p_netSessions, 0},
384 {"net-eval", p_netEval, 0},
385 #ifdef NET_PING
386 {"net-ping", p_netPing, 0},
387 #endif
388 {"net-error", p_netLastError, 0},
389 {NULL,NULL,0},