Skip to content

Commit

Permalink
Formatting updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
tacosontitan committed Jul 23, 2024
1 parent 3bdca00 commit 77cf097
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 37 deletions.
18 changes: 15 additions & 3 deletions src/Hussy.Net/Generators/BatchedRange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,24 @@ public static partial class Hussy
/// Generates a range of values starting with <c>1</c> through the specified <paramref name="count"/> value.
/// </summary>
/// <param name="count">The maximum value to include in the range.</param>
/// <param name="batchSize">Specifies the size of each batch.</param>
/// <returns>A range of values starting with <c>1</c> through the specified <paramref name="count"/> value.</returns>
public static IEnumerable<IEnumerable<int>> Gbr(int count, int batchSize) =>
public static IEnumerable<IEnumerable<int>> Gbr(
int count,
int batchSize) =>
Enumerable.Range(1, count).Chunk(batchSize);

/// <summary>
/// Generates a range of values from the specified <paramref name="start"/> through the specified <paramref name="count"/> value.
/// </summary>
/// <param name="start">The starting value for the range.</param>
/// <param name="count">The maximum value to include in the range.</param>
/// <param name="batchSize">Specifies the size of each batch.</param>
/// <returns>A range of values starting with <paramref name="start"/> through the specified <paramref name="count"/> value.</returns>
public static IEnumerable<IEnumerable<int>> Gbr(int start, int count, int batchSize) =>
public static IEnumerable<IEnumerable<int>> Gbr(
int start,
int count,
int batchSize) =>
Enumerable.Range(start, count).Chunk(batchSize);

/// <summary>
Expand All @@ -44,8 +51,13 @@ public static IEnumerable<IEnumerable<int>> Gbr(int start, int count, int batchS
/// <param name="start">The starting value for the range.</param>
/// <param name="count">The maximum value to include in the range.</param>
/// <param name="stepSize">The step value to use when generating the range.</param>
/// <param name="batchSize">Specifies the size of each batch.</param>
/// <returns>A range of values starting with <paramref name="start"/> through the specified <paramref name="count"/> value.</returns>
public static IEnumerable<IEnumerable<int>> Gbr(int start, int count, int stepSize, int batchSize)
public static IEnumerable<IEnumerable<int>> Gbr(
int start,
int count,
int stepSize,
int batchSize)
{
List<int> range = new(capacity: count);
for (int i = 0; i < count; i++)
Expand Down
9 changes: 7 additions & 2 deletions src/Hussy.Net/Generators/Range.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public static IEnumerable<int> Gr(int count) =>
/// <param name="start">The starting value for the range.</param>
/// <param name="count">The maximum value to include in the range.</param>
/// <returns>A range of values starting with <paramref name="start"/> through the specified <paramref name="count"/> value.</returns>
public static IEnumerable<int> Gr(int start, int count) =>
public static IEnumerable<int> Gr(
int start,
int count) =>
Enumerable.Range(start, count);

/// <summary>
Expand All @@ -45,7 +47,10 @@ public static IEnumerable<int> Gr(int start, int count) =>
/// <param name="count">The maximum value to include in the range.</param>
/// <param name="stepSize">The step value to use when generating the range.</param>
/// <returns>A range of values starting with <paramref name="start"/> through the specified <paramref name="count"/> value.</returns>
public static IEnumerable<int> Gr(int start, int count, int stepSize)
public static IEnumerable<int> Gr(
int start,
int count,
int stepSize)
{
List<int> range = new(capacity: count);
for (int i = 0; i < count; i++)
Expand Down
4 changes: 3 additions & 1 deletion src/Hussy.Net/Input/Prompt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public static partial class Hussy
/// <param name="message">The message to display to the user.</param>
/// <param name="formatProvider">The format provider to use for parsing the response. If null, the default format provider is used.</param>
/// <returns>The parsed user's response of type T.</returns>
public static T P<T>(string message, IFormatProvider? formatProvider = null)
public static T P<T>(
string message,
IFormatProvider? formatProvider = null)
where T : IParsable<T>
{
Console.Write(message);
Expand Down
4 changes: 3 additions & 1 deletion src/Hussy.Net/Linq/Batch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public static partial class Hussy
/// <param name="size">Specifies the size of the individual batches.</param>
/// <typeparam name="T">Specifies the type of the data in the <paramref name="source"/> sequence.</typeparam>
/// <returns>A collection of batches created from the specified <paramref name="source"/> sequence.</returns>
public static IEnumerable<IEnumerable<T>> B<T>(this IEnumerable<T> source, int size = 2) =>
public static IEnumerable<IEnumerable<T>> B<T>(
this IEnumerable<T> source,
int size = 2) =>
source.Chunk(size);
}
4 changes: 3 additions & 1 deletion src/Hussy.Net/Linq/Filter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public static partial class Hussy
/// <param name="source">The sequence to filter.</param>
/// <param name="predicate">A function to test each element for a condition.</param>
/// <returns>An IEnumerable{T} that contains elements from the input sequence that satisfy the condition.</returns>
public static IEnumerable<T> F<T>(this IEnumerable<T> source, Func<T, bool> predicate) =>
public static IEnumerable<T> F<T>(
this IEnumerable<T> source,
Func<T, bool> predicate) =>
source.Where(predicate);
}
26 changes: 0 additions & 26 deletions src/Hussy.Net/Linq/Join.cs

This file was deleted.

43 changes: 43 additions & 0 deletions src/Hussy.Net/Linq/JoinString.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
Copyright 2024 tacosontitan and contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

namespace Hussy.Net;

/// <summary>
/// Defines static methods for common programming tasks.
/// </summary>
public static partial class Hussy
{
/// <summary>
/// Joins the elements of the specified <paramref name="source"/> sequence
/// using the specified <paramref name="separator"/>.
/// </summary>
/// <typeparam name="T">Specifies the type of data in the sequence.</typeparam>
/// <param name="source">The source sequence of elements to join together.</param>
/// <param name="separator">
/// The separator that should be placed between each element; the default
/// value is <c>, </c>.
/// </param>
/// <returns>
/// The elements of the specified <paramref name="source"/> sequence
/// joined in a <see cref="string"/> using the specified
/// <paramref name="separator"/>.
/// </returns>
public static string Js<T>(
this IEnumerable<T> source,
string separator = ", ") =>
string.Join(separator, source);
}
4 changes: 3 additions & 1 deletion src/Hussy.Net/Logic/Divisibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public static partial class Hussy
/// <returns>
/// <c>true</c> if the value is divisible by all the operands; otherwise, <c>false</c>.
/// </returns>
public static bool Dvb(this int value, params int[] operands)
public static bool Dvb(
this int value,
params int[] operands)
{
foreach (int operand in operands)
if (value % operand != 0)
Expand Down
4 changes: 3 additions & 1 deletion src/Hussy.Net/Modules/FizzBuzz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public static void Fz(int count) =>
/// </summary>
/// <param name="start">The starting number.</param>
/// <param name="count">The number of values to print.</param>
public static void Fz(int start, int count) => Enumerable.Range(start, count)
public static void Fz(
int start,
int count) => Enumerable.Range(start, count)
.ToList()
.ForEach(PrintFizzBuzz);

Expand Down
4 changes: 3 additions & 1 deletion src/Hussy.Net/Output/WriteSeparator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ public static partial class Hussy
/// </summary>
/// <param name="character">The character used for the separator line. Default is '='.</param>
/// <param name="length">The length of the separator line. Default is 25.</param>
public static void Ws(char character = '=', int length = 25)
public static void Ws(
char character = '=',
int length = 25)
{
var separator = new string(character, length);
Console.WriteLine(separator);
Expand Down

0 comments on commit 77cf097

Please sign in to comment.