mirror of
https://github.com/janet-lang/janet
synced 2025-02-26 21:00:01 +00:00
Add table/clear.
This commit is contained in:
parent
e7ea39f410
commit
2e58f5f0d4
@ -2,6 +2,7 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
## 1.17.0 - Unreleased
|
## 1.17.0 - Unreleased
|
||||||
|
- Add `table/clear`
|
||||||
- Add build option to disable the threading library without disabling all threads.
|
- Add build option to disable the threading library without disabling all threads.
|
||||||
- Remove JPM from the main Janet distribution. Instead, JPM must be installed
|
- Remove JPM from the main Janet distribution. Instead, JPM must be installed
|
||||||
separately like any other package.
|
separately like any other package.
|
||||||
|
@ -311,6 +311,13 @@ static Janet cfun_table_clone(int32_t argc, Janet *argv) {
|
|||||||
return janet_wrap_table(janet_table_clone(table));
|
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[] = {
|
static const JanetReg table_cfuns[] = {
|
||||||
{
|
{
|
||||||
"table/new", cfun_table_new,
|
"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, "
|
"Create a copy of a table. Updates to the new table will not change the old table, "
|
||||||
"and vice versa.")
|
"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}
|
{NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user