( ce: ComputeEngine, name: string )
| 700 | if (symbols.length === 1) return symbols[0]; |
| 701 | |
| 702 | // Multiple symbols or no symbols - ambiguous |
| 703 | // Try to find common index variable names |
| 704 | const commonVars = ['n', 'k', 'i', 'j', 'm']; |
| 705 | for (const v of commonVars) { |
| 706 | if (symbols.includes(v)) return v; |
| 707 | } |
| 708 | |
| 709 | return undefined; |
| 710 | } |
| 711 | |
| 712 | /** |
| 713 | * Get the status of a sequence definition. |
| 714 | * |
| 715 | * Returns information about whether a sequence is complete, pending, or not defined. |
| 716 | * Supports both single-index and multi-index sequences. |
| 717 | */ |
| 718 | export function getSequenceStatus( |
| 719 | ce: ComputeEngine, |
| 720 | name: string |
| 721 | ): SequenceStatus { |
| 722 | // Check for pending sequence first |
| 723 | const pendingMap = pendingSequences.get(ce); |
| 724 | const pending = pendingMap?.get(name); |
| 725 | |
| 726 | if (pending) { |
| 727 | // Sort base indices appropriately |
| 728 | const baseIndices = Array.from(pending.base.keys()); |
| 729 | if (!pending.isMultiIndex) { |
| 730 | // Single-index: sort numerically |
| 731 | (baseIndices as number[]).sort((a, b) => a - b); |
| 732 | } |
| 733 | // Multi-index: keep as strings, sort lexicographically |
| 734 | |
| 735 | return { |
| 736 | status: 'pending', |
| 737 | hasBase: pending.base.size > 0, |
| 738 | hasRecurrence: !!pending.recurrence, |
| 739 | baseIndices, |
| 740 | variable: pending.recurrence?.variable, |
| 741 | variables: pending.recurrence?.variables, |
| 742 | }; |
| 743 | } |
| 744 | |
| 745 | // Check if symbol has subscriptEvaluate (complete sequence) |
| 746 | const def = ce.lookupDefinition(name); |
| 747 | if (def && isValueDef(def) && def.value.subscriptEvaluate) { |
| 748 | // It's a complete sequence - get details from registry |
| 749 | const registry = sequenceRegistry.get(ce); |
| 750 | const metadata = registry?.get(name); |
| 751 | |
| 752 | if (metadata) { |
| 753 | const baseIndices = Array.from(metadata.base.keys()); |
| 754 | if (!metadata.isMultiIndex) { |
| 755 | // Single-index: sort numerically |
| 756 | (baseIndices as number[]).sort((a, b) => a - b); |
| 757 | } |
| 758 | |
| 759 | return { |
nothing calls this directly
no test coverage detected