summaryrefslogtreecommitdiffstats
path: root/rand.c
Commit message (Collapse)AuthorAgeFilesLines
* Version 58txr-58Kaz Kylheku2012-02-251-1/+1
| | | | | | | | | | | | | | | | | * txr.c (version): Bumped. * txr.1: Bumped version and set date. * configure (txr_ver): Bumped. * RELNOTES: Updated. * eval.c (eval_init): Updated. * rand.c (rand): Function renamed to rnd due to a clash with standard C library (that does not show up when compiling as C++). * rand.h (rand): Declaration renamed to rnd.
* Introducing optional arguments.Kaz Kylheku2012-02-211-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * debug.c (help, show_bindings): put_string arguments reversed. * eval.c (bind_args): Support colon notation in interpreted function lambda lists for optional arguments. Improved error checking. (apply): Allow optional arguments to be left out. (dwim_loc): Reversed arguments to replace_str, replace_vec, replace_list. (eval_init): Numerous intrinsics now have arguments that are optional. New function rand introduced which reverses arguments relative to random. New intrinsic function hash introduced for alternative construction of hashes. * gc.c (sweep): Reversed arguments to put_char. * hash.c (weak_keys_k, weak_vals_k, equal_based_k): New keyword symbol variables. (hashv): New function. (hash_init): Intern new symbols. * hash.h (weak_keys_k, weak_vals_k, equal_based_k, hashv): Declared. * lib.c (colon_k): New keyword symbol variable. (replace_list, replace_str, replace_vec): Arguments rearranged. (tree_find): testfun becomes optional argument. (int_str): base becomes optional argument. (func_f0, func_f1, func_f2, func_f3, func_f4, func_n0, func_n1, func_n2, func_n3, func_n4, func_f0v, func_f1v, func_f2v, func_f3v, func_f4v, func_n0v, func_n1v, func_n2v, func_n3v, func_n4v, func_interp): Initialize optargs to zero. (func_n0o, func_n1o, func_n2o, func_n3o, func_n4o): New functions. (cobj_print_op): Reversed arguments to put_string. (find): testfun and keyfun become optional arguments. (replace): Parameters rearranged and arguments rearranged in calls to replace_list, replace_str and replace_vec. (obj_init): colon_k initialized. (obj_print, obj_pprint): Arguments reversed, and stream defaults to std_output. Arguments reversed in calls to put_char and put_string. (dump): Arguments reversed in call to put_char. * lib.h (struct func): sizes of minparam, fixparam bitfields adjusted. New bitfield optargs. New unnamed bitfield added so the previous ones add up to 16 bits. (colon_k): Declared. (func_n0o, func_n1o, func_n2o, func_n3o, func_n4o): Declared. (replace_list, replace_str, replace_vec, replace): Declarations updated. * match.c (debuglf, dump_shell_string, dump_byte_string, dump_var, do_output_line, extract): Reversed arguments to put_char and
* * match.c (LOG_MATCH): Use < in format directive instead of -.Kaz Kylheku2011-12-281-1/+2
| | | | * rand.c (random): Add back missing declaration.
* * rand.c (make_state): Use ANSI C syntax for prototyped function of noKaz Kylheku2011-12-271-2/+1
| | | | | | arguments. This snuck through due to working with a C++ compiler. (random): Fixed unused variable warning that happens on 32-bit-pointer platforms.
* * rand.c (rand32): Moved.Kaz Kylheku2011-12-231-21/+25
| | | | | | (make_random_state): After initializing, retrieve eight random numbers to clear pathological initial behavior leading to duplicate values.
* * arith.c (highest_bit): Changing to external linkage.Kaz Kylheku2011-12-231-19/+48
| | | | | | | | * arith.h (highest_bit): Declared. * rand.c (random): Rewrote using different algorithm which ensures even distribution, and avoids doing a bignum mod operation.
* * rand.c (random): Fix for 64 bit fixnums: stick two random numbersKaz Kylheku2011-12-221-0/+4
| | | | | together. Otherwise for fixnum moduli, we get only a 32 bit number no matter what the modulus is.
* * arith.c (normalize): Linkage changed to extern.Kaz Kylheku2011-12-211-1/+1
| | | | | | | | * arith.h (normalize): Declared. * rand.c (random): Bugfix: normalize the bignum before returning it. * txr.1: Doc stubs for PRNG functionality.
* * rand.c: Added comment about source of algorithm.Kaz Kylheku2011-12-211-0/+4
|
* * rand.c (random): Bugfix: not building up sufficiently large bignums.Kaz Kylheku2011-12-211-3/+12
| | | | Work properly when mp_digit is smaller than 32 bits.
* * Makefile (OBJS): new object file, rand.o.Kaz Kylheku2011-12-211-0/+199
* eval.c: Includes rand.h header. (eval_init): New variable and functions from rand module registered. * lib.c: Includes rand.h header. (init): Call rand_init. * rand.c: New file. * rand.h: New file.