From 034f54b14416dd411fbd204f8b5465b8bc462b76 Mon Sep 17 00:00:00 2001 From: ame Date: Wed, 18 Oct 2023 16:30:38 -0500 Subject: md5 and sorting improvments --- src/table.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/table.h') diff --git a/src/table.h b/src/table.h index 25c51fa..f3c68ff 100644 --- a/src/table.h +++ b/src/table.h @@ -1,13 +1,16 @@ #include "lua.h" -#include "util.h" - -#define i_swap(A,B) double temp = A; A = B; B = temp; +#include "i_util.h" +#include "i_common.h" int l_len(lua_State*); //[double+int] -> i int l_reverse(lua_State*); //[double+int] -> arr[N] int l_greatest(lua_State*); //[double+int] -> i int l_least(lua_State*); //[double+int] -> i int l_shuffle(lua_State*); //[double+int] -> arr[N] +int l_sum(lua_State*); //[double+int] -> i + +int l_indexof(lua_State*); //[double+int], item -> i +int l_sindexof(lua_State*);//[double+int] (greatest -> least), item -> i //comparison sorts int l_quicksort(lua_State*); //[double+int] -> arr[N] (greatest -> least) @@ -18,7 +21,7 @@ int l_heapsort(lua_State*); //[double+int] -> arr[N] (greatest -> least) //non-comparison sorts //good for large arrays filled with small values -int l_countingsort(lua_State*); //[int], arr[N] >= 0 -> arr[N] (least -> greatest) +int l_countingsort(lua_State*); //[int] (arr[N] >= 0) -> arr[N] (least -> greatest) //esoteric sorts int l_miraclesort(lua_State*); //[double+int] -> arr[-∞<=N<=∞] (greatest -> least) @@ -33,7 +36,11 @@ static const luaL_Reg array_function_list [] = { {"greatest",l_greatest}, {"least",l_least}, {"shuffle",l_shuffle}, + {"sum",l_sum}, + {"index",l_indexof}, + {"sindex",l_sindexof}, + {"quicksort",l_quicksort}, {"mergesort",l_mergesort}, {"shellsort",l_shellsort}, -- cgit v1.2.3