Repository navigation
Former Compile functions match their arguments again - #7
Merged
Merged
Conversation
LP, NC, NKS, NthPair, RGFs1, TC, TR and TRAcyclic were compiled functions; their uncompiled definitions took arguments as n_?Integer, which matches nothing (Integer[n] is never True), so they stayed unevaluated. Integer arguments are now n_Integer and integer vectors and matrices _List. That makes RandomGraph, NextComposition, NextKSubset, RandomSetPartition, TransitiveClosure, TransitiveReduction and HasseDiagram give graphs and lists again. LP assigned to parts of its argument, which only a compiled function can do; it now works on a local copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Like the other former Compile functions, their uncompiled definitions tested arrays with ?NumberQ or ?IntegerQ, which a list never passes, so weighted AllPairsShortestPath (and with it Eccentricity, Diameter and Radius of weighted graphs) and BellmanFord stayed unevaluated. Arrays are now matched as _List. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
Thanks! |
This was referenced Oct 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while running the examples of Skiena and Pemmaraju's Computational Discrete Mathematics with this package under Mathics3, comparing every result with WMA 15.
Several internal functions were
Compiled in the original. Their uncompiled definitions tested the arguments with?Integer,?IntegerQor?NumberQ, which a list never passes.n_?Integermatches nothing at all, sinceInteger[n]is never True. So these functions stayed unevaluated, and so did everything built on them:LPn_?Integern_IntegerLexicographicPermutationsNCl_?Integerl_ListNextCompositionNKSss_?Integerss_ListNextKSubsetNthPairn_?Integern_IntegerRandomGraphRGFs1n_?Integern_IntegerRGFsTCe_?Integere_ListTransitiveClosureTR,TRAcyclicclosure_?Integerclosure_ListTransitiveReduction,HasseDiagramDP1,DP2p_?NumberQ,q_?IntegerQ_ListAllPairsShortestPath,Eccentricity,Diameter,RadiusBFe1_?IntegerQ,w1_?NumberQ, ..._ListBellmanFordLPalso assigned to parts of its argument#, which only a compiled function can do; it now works on a local copy.I checked these functions against WMA 15's Combinatorica, for example
AllPairsShortestPath,BellmanFord,EccentricityandDiameteron a weightedCycle[5]. With Mathics3/mathics-core#2088 (BinomialDistribution),RandomGraphgives graphs again.Package tests: 18 passed.
🤖 Generated with Claude Code