Skip to content

Commit 1b6cc02

Browse files
author
sogaiu
committed
Tweak apply and short-fn docstrings
1 parent 410f8d6 commit 1b6cc02

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

src/boot/boot.janet

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2345,17 +2345,11 @@
23452345

23462346
(defmacro short-fn
23472347
```
2348-
Shorthand for `fn`. Arguments are given as `$n`, where `n` is the 0-indexed
2349-
argument of the function. `$` is also an alias for the first (index 0) argument.
2350-
The `$&` symbol will make the anonymous function variadic if it appears in the
2351-
body of the function, and can be combined with positional arguments.
2352-
2353-
Example usage:
2354-
2355-
(short-fn (+ $ $)) # A function that doubles its arguments.
2356-
(short-fn (string $0 $1)) # accepting multiple args.
2357-
|(+ $ $) # use pipe reader macro for terse function literals.
2358-
|(+ $&) # variadic functions
2348+
Shorthand for `fn`. Arguments are given as `$n`, where `n` is the
2349+
0-indexed argument of the function. `$` is also an alias for the
2350+
first (index 0) argument. The `$&` symbol will make the anonymous
2351+
function variadic if it appears in the body of the function, and
2352+
can be combined with positional arguments.
23592353
```
23602354
[arg &opt name]
23612355
(var max-param-seen -1)

src/core/corelib.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,12 +1002,11 @@ static void make_apply(JanetTable *env) {
10021002
janet_quick_asm(env, JANET_FUN_APPLY | JANET_FUNCDEF_FLAG_VARARG,
10031003
"apply", 1, 1, INT32_MAX, 6, apply_asm, sizeof(apply_asm),
10041004
JDOC("(apply f & args)\n\n"
1005-
"Applies a function to a variable number of arguments. Each element in args "
1006-
"is used as an argument to f, except the last element in args, which is expected to "
1007-
"be an array-like. Each element in this last argument is then also pushed as an argument to "
1008-
"f. For example:\n\n"
1009-
"\t(apply + 1000 (range 10))\n\n"
1010-
"sums the first 10 integers and 1000."));
1005+
"Applies a function f to a variable number of arguments. Each "
1006+
"element in args is used as an argument to f, except the last "
1007+
"element in args, which is expected to be an array or a tuple. "
1008+
"Each element in this last argument is then also pushed as an "
1009+
"argument to f."));
10111010
}
10121011

10131012
static const uint32_t error_asm[] = {

0 commit comments

Comments
 (0)