1
0
mirror of https://github.com/janet-lang/janet synced 2025-11-13 13:57:19 +00:00

Remove tuple/append and tuple/prepend.

Use the splice special instead.
This commit is contained in:
Calvin Rose
2019-02-20 21:08:54 -05:00
parent a982f351d7
commit 811b1825cb
4 changed files with 6 additions and 37 deletions

View File

@@ -311,7 +311,7 @@
[i preds &]
(default preds @['and])
(if (>= i len)
(tuple/prepend body 'do)
['do ;body]
(do
(def {i bindings
(+ i 1) verb

View File

@@ -106,26 +106,6 @@ static Janet cfun_tuple_slice(int32_t argc, Janet *argv) {
return janet_wrap_tuple(janet_tuple_n(view.items + range.start, range.end - range.start));
}
static Janet cfun_tuple_prepend(int32_t argc, Janet *argv) {
janet_arity(argc, 1, -1);
JanetView view = janet_getindexed(argv, 0);
Janet *n = janet_tuple_begin(view.len - 1 + argc);
memcpy(n - 1 + argc, view.items, sizeof(Janet) * view.len);
for (int32_t i = 1; i < argc; i++) {
n[argc - i - 1] = argv[i];
}
return janet_wrap_tuple(janet_tuple_end(n));
}
static Janet cfun_tuple_append(int32_t argc, Janet *argv) {
janet_arity(argc, 1, -1);
JanetView view = janet_getindexed(argv, 0);
Janet *n = janet_tuple_begin(view.len - 1 + argc);
memcpy(n, view.items, sizeof(Janet) * view.len);
memcpy(n + view.len, argv + 1, sizeof(Janet) * (argc - 1));
return janet_wrap_tuple(janet_tuple_end(n));
}
static Janet cfun_tuple_type(int32_t argc, Janet *argv) {
janet_fixarity(argc, 1);
const Janet *tup = janet_gettuple(argv, 0);
@@ -150,19 +130,6 @@ static const JanetReg tuple_cfuns[] = {
"they default to 0 and the length of arrtup respectively."
"Returns the new tuple.")
},
{
"tuple/append", cfun_tuple_append,
JDOC("(tuple/append tup & items)\n\n"
"Returns a new tuple that is the result of appending "
"each element in items to tup.")
},
{
"tuple/prepend", cfun_tuple_prepend,
JDOC("(tuple/prepend tup & items)\n\n"
"Prepends each element in items to tuple and "
"returns a new tuple. Items are prepended such that the "
"last element in items is the first element in the new tuple.")
},
{
"tuple/type", cfun_tuple_type,
JDOC("(tuple/type tup)\n\n"