Implement generic operators comparable to JonSkeet.MiscUtil #118
+482
β0
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.
π Implementation Complete
This pull request implements comprehensive generic operator functionality comparable to JonSkeet.MiscUtil, addressing issue #31.
π Issue Reference
Fixes #31
β¨ Key Features Implemented
Basic Arithmetic Operations
Add<T>(T, T)- Generic additionSubtract<T>(T, T)- Generic subtractionMultiply<T>(T, T)- Generic multiplicationDivide<T>(T, T)- Generic divisionNegate<T>(T)- Generic negationComparison Operations
Min<T>(T, T)- Returns smaller valueMax<T>(T, T)- Returns larger valueAbs<T>(T)- Absolute valueSign<T>(T)- Sign indication (-1, 0, 1)Aggregate Operations
Sum<T>(IEnumerable<T>)- Sums sequence of valuesAverage<T>(IEnumerable<T>)- Computes average of sequenceIdentity Constants
Zero<T>()- Gets additive identityOne<T>()- Gets multiplicative identityπ― Modern .NET 8 Approach
This implementation uses .NET 8's modern generic math system instead of JonSkeet.MiscUtil's legacy approach:
β Testing
int,long,double,ulongπ Benefits
π Backward Compatibility
All existing functionality remains unchanged:
Factorial<T>methodsCatalan<T>methodsIsPowerOfTwo<T>methodsThis PR was implemented using modern .NET 8 patterns to provide superior functionality compared to JonSkeet.MiscUtil