From 1c583965749a40cdbe15846c2487f32a426dcbeb Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 28 Jun 2023 21:26:33 -0700 Subject: 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. --- autoload.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'autoload.c') 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)); } -- cgit v1.2.3