Skip to content
This repository has been archived by the owner on Jul 21, 2024. It is now read-only.

Commit

Permalink
Added GetResultsOf() method (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
lpeyr committed May 8, 2022
1 parent 07aeb25 commit e801db2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions LeoCorpLibrary.Core/Maths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ public static double DegreesToRadians(double degrees)
/// <returns>A <see cref="double"/> value, the ngeative of the number.</returns>
public static double GetNegative(double n) => n <= 0 ? n : -n;

public static double[] GetResultsOf(Func<double, double> function, params double[] numbers)
{
double[] results = new double[numbers.Length]; // Create a new array that will contain the results once the other method is applied to each number
for (int i = 0; i < numbers.Length; i++) // For each number
{
results[i] = function(numbers[i]); // Apply the method to the number
}
return results; // Return the results
}

/// <summary>
/// Returns the factorial of a specified number.
/// </summary>
Expand Down

0 comments on commit e801db2

Please sign in to comment.