(
rational: Rational,
radical: number
)
| 690 | options, |
| 691 | metadata |
| 692 | ); |
| 693 | } |
| 694 | if (isFunction(args[0], 'Block')) { |
| 695 | const block = args[0]; |
| 696 | if (block.nops === 1) { |
| 697 | const params = args.slice(1); |
| 698 | // `["Function", ["Block", ["Add", "_1", 2]], "_1"]` is written |
| 699 | // `["Function", ["Add", "_1", 2]]`: with no parameter operand, |
| 700 | // boxing reads the parameters off the wildcards of the body |
| 701 | // (`anonymousParameters`, `function-utils.ts`), which takes `_1`, |
| 702 | // `_2`, … in order for every wildcard the body mentions. The |
| 703 | // shorthand is therefore used only when the parameter list is |
| 704 | // exactly what that reading gives back: the parameters are `_1`, |
| 705 | // `_2`, …, `_n` in order, and the wildcards the body mentions are |
| 706 | // exactly those. That reading renames a bare `_` to `_1` and stops |
| 707 | // at `_9`, so a body with a bare `_`, a free wildcard outside the |
| 708 | // list (`_2` in `["Function", ["Add", "_1", "_2"], "_1"]`), or a |
| 709 | // list past `_9` keeps its parameters. A parameter list that differs |
| 710 | // (a named parameter such as `x_1`, an unused `_2`, a gap, a list |
| 711 | // starting at `_2`) is kept too, or the shorthand would change the |
| 712 | // arity or drop the parameter. The former `["Function", "Add"]` |
| 713 | // spelling for `_1, _2 \mapsto Add(_1, _2)` was dropped: boxed, it is |
| 714 | // a function of no argument whose body is the symbol `Add`. |
| 715 | // |
| 716 | // The wildcards are read as boxing reads them: a wildcard inside a |
| 717 | // nested `Function` literal is that literal's parameter, not one of |
| 718 | // this literal's (`freeAnonymousSlots`). A parameter used only in a |
| 719 | // nested literal therefore keeps the list, or the shorthand would |
| 720 | // re-box with fewer parameters. |
| 721 | const body = block.op1; |
| 722 | const bodyWildcards = freeAnonymousSlots(body); |
| 723 | const wildcardParams = |
no test coverage detected