mirror of
https://github.com/janet-lang/janet
synced 2025-02-22 03:00:02 +00:00
Merge pull request #1555 from sogaiu/tweak-apply-short-fn-docstrings
Tweak apply and short-fn docstrings
This commit is contained in:
commit
5f550ea5d4
@ -2345,17 +2345,11 @@
|
||||
|
||||
(defmacro short-fn
|
||||
```
|
||||
Shorthand for `fn`. Arguments are given as `$n`, where `n` is the 0-indexed
|
||||
argument of the function. `$` is also an alias for the first (index 0) argument.
|
||||
The `$&` symbol will make the anonymous function variadic if it appears in the
|
||||
body of the function, and can be combined with positional arguments.
|
||||
|
||||
Example usage:
|
||||
|
||||
(short-fn (+ $ $)) # A function that doubles its arguments.
|
||||
(short-fn (string $0 $1)) # accepting multiple args.
|
||||
|(+ $ $) # use pipe reader macro for terse function literals.
|
||||
|(+ $&) # variadic functions
|
||||
Shorthand for `fn`. Arguments are given as `$n`, where `n` is the
|
||||
0-indexed argument of the function. `$` is also an alias for the
|
||||
first (index 0) argument. The `$&` symbol will make the anonymous
|
||||
function variadic if it appears in the body of the function, and
|
||||
can be combined with positional arguments.
|
||||
```
|
||||
[arg &opt name]
|
||||
(var max-param-seen -1)
|
||||
|
@ -1002,12 +1002,11 @@ static void make_apply(JanetTable *env) {
|
||||
janet_quick_asm(env, JANET_FUN_APPLY | JANET_FUNCDEF_FLAG_VARARG,
|
||||
"apply", 1, 1, INT32_MAX, 6, apply_asm, sizeof(apply_asm),
|
||||
JDOC("(apply f & args)\n\n"
|
||||
"Applies a function to a variable number of arguments. Each element in args "
|
||||
"is used as an argument to f, except the last element in args, which is expected to "
|
||||
"be an array-like. Each element in this last argument is then also pushed as an argument to "
|
||||
"f. For example:\n\n"
|
||||
"\t(apply + 1000 (range 10))\n\n"
|
||||
"sums the first 10 integers and 1000."));
|
||||
"Applies a function f to a variable number of arguments. Each "
|
||||
"element in args is used as an argument to f, except the last "
|
||||
"element in args, which is expected to be an array or a tuple. "
|
||||
"Each element in this last argument is then also pushed as an "
|
||||
"argument to f."));
|
||||
}
|
||||
|
||||
static const uint32_t error_asm[] = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user