summaryrefslogtreecommitdiffstats
path: root/autoload.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-06-28 21:26:33 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-06-28 21:26:33 -0700
commit1c583965749a40cdbe15846c2487f32a426dcbeb (patch)
tree394bd3a195c221e3c885d474b036b52ebc4ac0e3 /autoload.c
parent8ee92a458a4b854b4a7e726975c1197be877c500 (diff)
downloadtxr-1c583965749a40cdbe15846c2487f32a426dcbeb.tar.gz
txr-1c583965749a40cdbe15846c2487f32a426dcbeb.tar.bz2
txr-1c583965749a40cdbe15846c2487f32a426dcbeb.zip
New cached sorting functions.
These functions are useful when sorting a sequence using an expensive keyfun. * autoload.c (csort_set_entries, csort_instantiate): New static functions. (autlod_init): Register autoloading of csort module via new functions. * stdlib/csort.tl: New file. * tests/012/sort.tl: csort functions included in tests. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
Diffstat (limited to 'autoload.c')
-rw-r--r--autoload.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/autoload.c b/autoload.c
index d384879a..b87d560a 100644
--- a/autoload.c
+++ b/autoload.c
@@ -955,6 +955,22 @@ static val load_args_instantiate(void)
return nil;
}
+static val csort_set_entries(val fun)
+{
+ val name[] = {
+ lit("csort"), lit("cnsort"), lit("cssort"), lit("csnsort"),
+ nil
+ };
+ autoload_set(al_fun, name, fun);
+ return nil;
+}
+
+static val csort_instantiate(void)
+{
+ load(scat2(stdlib_path, lit("csort")));
+ return nil;
+}
+
val autoload_reg(val (*instantiate)(void),
val (*set_entries)(val))
{
@@ -1024,6 +1040,7 @@ void autoload_init(void)
autoload_reg(constfun_instantiate, constfun_set_entries);
autoload_reg(expander_let_instantiate, expander_let_set_entries);
autoload_reg(load_args_instantiate, load_args_set_entries);
+ autoload_reg(csort_instantiate, csort_set_entries);
reg_fun(intern(lit("autoload-try-fun"), system_package), func_n1(autoload_try_fun));
}