Skip to content

Add support for missing argument forms and options - #1972

Merged
ad-si merged 1 commit into
mainfrom
claude/clever-cori-ndkf5l
Oct 29, 2026
Merged

ad-si merged 1 commit into
mainfrom
claude/clever-cori-ndkf5l

Conversation

@ad-si

@ad-si ad-si commented Oct 29, 2026

Copy link
Copy Markdown
Owner

This PR implements support for numerous missing argument forms and optional parameters discovered through systematic testing of documented examples against the reference implementation.

Summary

Adds comprehensive support for alternative argument forms and optional parameters across 40+ functions, enabling more flexible and powerful usage patterns while maintaining full compatibility with existing code.

Key Changes

Argument Form Expansions:

  • Head[expr, wrapper] - wraps the head in a specified wrapper
  • Thread[expr, h, positions] - threads over specified positions with support for negative indices and ranges
  • Partition[list, UpTo[n], offset] - partitions with variable-length chunks and custom offsets
  • Map/Apply with Heads -> True|False option - includes/excludes heads in level-based operations
  • Do with symbolic bounds and infinite upper bounds - supports symbolic iteration and early termination
  • Fold/FoldList operator form - curried application with initial value
  • DSolve/DSolveValue single-argument form - automatically extracts unknowns from equations
  • DatePlus[n] - shorthand for DatePlus[Today, n]
  • PowerRange[max] - shorthand for PowerRange[1, max]
  • ParentDirectory[dir, n] - navigate n levels up the directory tree
  • Uncompress[data, wrapper] - wraps decompressed data in a specified head

New Mathematical Functions:

  • FromDigits[string, "Roman"] - Roman numeral parsing
  • MatrixPower[matrix, n, vector] - matrix power applied to a vector
  • Inverse trigonometric functions at infinity (ArcSin[Infinity], etc.)
  • Complex component functions at infinity (Re[ComplexInfinity], etc.)
  • Two-argument ArcTan with infinite coordinates
  • KroneckerDelta for non-zero numeric quantities
  • Coefficient/CoefficientList with Modulus option
  • DiagonalMatrix with TargetStructure -> "Dense"|"Sparse" option
  • RandomInteger for big integers beyond machine precision
  • RandomColor with color templates containing blanks
  • Inner with general heads
  • ConjugateTranspose[matrix, permutation] - permuted conjugate transpose
  • Fit with design matrix form
  • NSolve with domain and precision arguments
  • ToBoxes[expr, StandardForm] - explicit form specification
  • Nielsen polylogarithm PolyLog[n, p, z] with reductions and derivatives
  • EllipticTheta[a, q] - theta constant form
  • LegendreP[n, m, 1, z] - type specification (type 1 is default)
  • UnitBox/UnitTriangle/HeavisideLambda with exact numeric arguments
  • DivisorSigma[k, n] with symbolic and rational orders
  • GroupSupport/GroupOrbits single-argument forms
  • MaximalBy/MinimalBy/TakeLargestBy/TakeSmallestBy with ordering functions
  • InverseErf[a, z] - generalized inverse error function
  • SquareFreeQ[poly, x] - square-free test with respect to a variable
  • KeyExistsQ operator form and rule support
  • ReplaceList operator form
  • StringReplacePart operator form
  • Sort/Ordering with ordering functions (Order, NumericalOrder, Less)
  • PolyLog derivative support

Implementation Details:

  • Infinite argument handling for inverse trig and complex functions follows Wolfram Language semantics
  • Big integer random generation uses rejection sampling for uniform distribution
  • Color template filling supports arbitrary nesting of color models
  • Symbolic Do iterator bounds support numeric spans (e.g., {n, x, x+3y, y})
  • Partition with UpTo respects custom offsets while allowing short final chunks
  • Map/Apply with Heads option treats

https://claude.ai/code/session_016qTZSpPE4Ja7tjbZmw24hT

…sweep

Argument forms:
- Head[expr, h]; Fold[f][x, list]; FromDigits[s, "Roman"]
- Thread[expr, h, spec] with All, None, -n and {m, n, s} position specs
- Partition[list, UpTo[n], d]
- Map/Apply[f, expr, levelspec, Heads -> True|False]
- Do with symbolic bounds of numeric span ({n, x, x + 3 y, y}) and an
  Infinity upper bound
- MatrixPower[m, n, v]; ConjugateTranspose[a, perm]; Fit[{m, v}]
- Inner over two expressions with the same non-List head
- DSolve[eqns] / DSolveValue[eqns] reading the unknowns off the derivatives
- NSolve[eqns, vars, dom, prec]; ToBoxes[expr, StandardForm]; DatePlus[n]
- PolyLog[n, p, z] (p = 1 and n = 0 reductions, z-derivative);
  EllipticTheta[a, q]; LegendreP[n, m, 1, z]
- RandomInteger with big-integer bounds; RandomColor[RGBColor[_, _, _], n]
- UnitBox/UnitTriangle/HeavisidePi/HeavisideLambda of several variables
  and of exact numeric constants (Pi, Sqrt[2]/4)
- DivisorSigma with a symbolic or rational order
- Operator forms KeyExistsQ[k][a], ReplaceList[rules][e],
  StringReplacePart[snew, pos][s]; KeyExistsQ of a single rule
- MaximalBy/MinimalBy/TakeLargestBy/TakeSmallestBy[list, f, n, p]
- InverseErf[x0, s]; SquareFreeQ[poly, x]; PowerRange[max];
  ParentDirectory[dir, n]; Uncompress[s, h]
- GroupSupport (new) and GroupOrbits[group]
- Inverse trig, Arg, Re, Im, Conjugate at Infinity/ComplexInfinity;
  ArcTan[x, y] with one infinite coordinate; KroneckerDelta of nonzero
  numeric constants

Options:
- Coefficient/CoefficientList Modulus -> m
- DiagonalMatrix TargetStructure -> "Dense" | "Sparse" | Automatic

Fixes found on the way:
- Sort/Ordering ordering functions answering -1 (Order, NumericalOrder)
  now put the second element first
- Compress[Unevaluated[e]] compresses e as written; Uncompress evaluates a
  text payload

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016qTZSpPE4Ja7tjbZmw24hT
@claude

claude Bot commented Oct 29, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@ad-si
ad-si merged commit afd00a3 into main Oct 29, 2026
4 checks passed
@ad-si
ad-si deleted the claude/clever-cori-ndkf5l branch October 29, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants