mirror of
https://github.com/janet-lang/janet
synced 2024-11-24 17:27:18 +00:00
update docstrings for string/slice
and tuple/slice
This commit is contained in:
parent
bdefd3ba1e
commit
c2e55b5486
@ -175,8 +175,9 @@ JANET_CORE_FN(cfun_string_slice,
|
|||||||
"Returns a substring from a byte sequence. The substring is from "
|
"Returns a substring from a byte sequence. The substring is from "
|
||||||
"index `start` inclusive to index `end`, exclusive. All indexing "
|
"index `start` inclusive to index `end`, exclusive. All indexing "
|
||||||
"is from 0. `start` and `end` can also be negative to indicate indexing "
|
"is from 0. `start` and `end` can also be negative to indicate indexing "
|
||||||
"from the end of the string. Note that index -1 is synonymous with "
|
"from the end of the string. Note that if `start` is negative it is "
|
||||||
"index `(length bytes)` to allow a full negative slice range. ") {
|
"exclusive, and if `end` is negative it is inclusive, to allow a full "
|
||||||
|
"negative slice range.") {
|
||||||
JanetByteView view = janet_getbytes(argv, 0);
|
JanetByteView view = janet_getbytes(argv, 0);
|
||||||
JanetRange range = janet_getslice(argc, argv);
|
JanetRange range = janet_getslice(argc, argv);
|
||||||
return janet_stringv(view.bytes + range.start, range.end - range.start);
|
return janet_stringv(view.bytes + range.start, range.end - range.start);
|
||||||
|
@ -69,9 +69,9 @@ JANET_CORE_FN(cfun_tuple_slice,
|
|||||||
"inclusive to index `end` exclusive. If `start` or `end` are not provided, "
|
"inclusive to index `end` exclusive. If `start` or `end` are not provided, "
|
||||||
"they default to 0 and the length of `arrtup`, respectively. "
|
"they default to 0 and the length of `arrtup`, respectively. "
|
||||||
"`start` and `end` can also be negative to indicate indexing "
|
"`start` and `end` can also be negative to indicate indexing "
|
||||||
"from the end of the input. Note that index -1 is synonymous with "
|
"from the end of the input. Note that if `start` is negative it is "
|
||||||
"index `(length arrtup)` to allow a full negative slice range. "
|
"exclusive, and if `end` is negative it is inclusive, to allow a full "
|
||||||
"Returns the new tuple.") {
|
"negative slice range. Returns the new tuple.") {
|
||||||
JanetView view = janet_getindexed(argv, 0);
|
JanetView view = janet_getindexed(argv, 0);
|
||||||
JanetRange range = janet_getslice(argc, argv);
|
JanetRange range = janet_getslice(argc, argv);
|
||||||
return janet_wrap_tuple(janet_tuple_n(view.items + range.start, range.end - range.start));
|
return janet_wrap_tuple(janet_tuple_n(view.items + range.start, range.end - range.start));
|
||||||
|
Loading…
Reference in New Issue
Block a user