1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-28 11:09:54 +00:00

Add table/clear.

This commit is contained in:
Calvin Rose 2021-07-21 19:58:42 -05:00
parent e7ea39f410
commit 2e58f5f0d4
2 changed files with 13 additions and 0 deletions

View File

@ -2,6 +2,7 @@
All notable changes to this project will be documented in this file.
## 1.17.0 - Unreleased
- Add `table/clear`
- Add build option to disable the threading library without disabling all threads.
- Remove JPM from the main Janet distribution. Instead, JPM must be installed
separately like any other package.

View File

@ -311,6 +311,13 @@ static Janet cfun_table_clone(int32_t argc, Janet *argv) {
return janet_wrap_table(janet_table_clone(table));
}
static Janet cfun_table_clear(int32_t argc, Janet *argv) {
janet_fixarity(argc, 1);
JanetTable *table = janet_gettable(argv, 0);
janet_table_clear(table);
return janet_wrap_table(table);
}
static const JanetReg table_cfuns[] = {
{
"table/new", cfun_table_new,
@ -350,6 +357,11 @@ static const JanetReg table_cfuns[] = {
"Create a copy of a table. Updates to the new table will not change the old table, "
"and vice versa.")
},
{
"table/clear", cfun_table_clear,
JDOC("(table/clear tab)\n\n"
"Remove all key-value pairs in a table and return the modified table `tab`.")
},
{NULL, NULL, NULL}
};