diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2024-07-01 18:10:49 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2024-07-01 18:10:49 -0700 |
commit | 77deceded0e5c9143e01d07a19eb219b3273151b (patch) | |
tree | f2447cc6c50cf459a3c271c25a7b4d4437b6280b /eval.c | |
parent | c23882b230f65ddc87742e206a56270d09c73684 (diff) | |
download | txr-77deceded0e5c9143e01d07a19eb219b3273151b.tar.gz txr-77deceded0e5c9143e01d07a19eb219b3273151b.tar.bz2 txr-77deceded0e5c9143e01d07a19eb219b3273151b.zip |
New functions: cshuffle and cnshuffle.
These functions find random cyclic permutations.
* eval.c (eval_init): Register cshuffle and cnshuffle
intrinsics.
* lib.c (nshuffle_impl): New static function, formed out of
nshuffle.
(nhuffle): Now wrapper around nshuffle_impl.
(shuffle): Also wraps nshuffle_impl rather than nshuffle.
(cnshuffle, cshuffle): New funtions.
* lib.h (cnshuffle, cshuffle): Declared.
* txr.1: Documented new functions. Also added warning
about limitations on permutation reachability in relation
to PRNG state size.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -7787,6 +7787,8 @@ void eval_init(void) reg_fun(intern(lit("ssort"), user_package), func_n3o(ssort, 1)); reg_fun(intern(lit("nshuffle"), user_package), func_n2o(nshuffle, 1)); reg_fun(intern(lit("shuffle"), user_package), func_n2o(shuffle, 1)); + reg_fun(intern(lit("cnshuffle"), user_package), func_n2o(cnshuffle, 1)); + reg_fun(intern(lit("cshuffle"), user_package), func_n2o(cshuffle, 1)); reg_fun(intern(lit("find"), user_package), func_n4o(find, 2)); reg_fun(intern(lit("rfind"), user_package), func_n4o(rfind, 2)); reg_fun(intern(lit("find-if"), user_package), func_n3o(find_if, 2)); |