Skip to content

Instantly share code, notes, and snippets.

@karenpayneoregon
Last active January 3, 2025 15:15
Show Gist options
  • Save karenpayneoregon/4375e73d295ad505ba35a0ea3b05c3f7 to your computer and use it in GitHub Desktop.
Save karenpayneoregon/4375e73d295ad505ba35a0ea3b05c3f7 to your computer and use it in GitHub Desktop.
Array/List merge - ChatGPT

Given the following two extension methods, ChatGPT was asked to create extension methods accepting up to ten arguments. It took ChatGPT roughly twenty seconds to complete the task.

If a developer was given the same task without any A.I. assessment there would be the chance of mistakes along with taking much more time to complete the task.

Note, Jetbrains AI assistant and GitHub Copilot could had been used.

Prompt used (1,2,3 existed)

Add methods for 4,5,6,7,8,9,10 using the following as the pattern

public static T[] Merge<T>(this T[] container, T[] T1) where T : INumber<T>
    => [.. container, .. T1];

public static List<T> Merge<T>(this List<T> container, T[] T1) where T : INumber<T>
    => [.. container, .. T1];
using System.Numerics;
namespace Extensions;
public static class GenericINumberExtensions
{
public static T[] Merge<T>(this T[] container, T[] T1) where T : INumber<T>
=> [.. container, .. T1];
public static T[] Merge<T>(this T[] container, T[] T1, T[] T2) where T : INumber<T>
=> [.. container, .. T1, .. T2];
public static T[] Merge<T>(this T[] container, T[] T1, T[] T2, T[] T3) where T : INumber<T>
=> [.. container, .. T1, .. T2, .. T3];
public static T[] Merge<T>(this T[] container, T[] T1, T[] T2, T[] T3, T[] T4) where T : INumber<T>
=> [.. container, .. T1, .. T2, .. T3, .. T4];
public static T[] Merge<T>(this T[] container, T[] T1, T[] T2, T[] T3, T[] T4, T[] T5) where T : INumber<T>
=> [.. container, .. T1, .. T2, .. T3, .. T4, .. T5];
public static T[] Merge<T>(this T[] container, T[] T1, T[] T2, T[] T3, T[] T4, T[] T5, T[] T6) where T : INumber<T>
=> [.. container, .. T1, .. T2, .. T3, .. T4, .. T5, .. T6];
public static T[] Merge<T>(this T[] container, T[] T1, T[] T2, T[] T3, T[] T4, T[] T5, T[] T6, T[] T7) where T : INumber<T>
=> [.. container, .. T1, .. T2, .. T3, .. T4, .. T5, .. T6, .. T7];
public static T[] Merge<T>(this T[] container, T[] T1, T[] T2, T[] T3, T[] T4, T[] T5, T[] T6, T[] T7, T[] T8) where T : INumber<T>
=> [.. container, .. T1, .. T2, .. T3, .. T4, .. T5, .. T6, .. T7, .. T8];
public static T[] Merge<T>(this T[] container, T[] T1, T[] T2, T[] T3, T[] T4, T[] T5, T[] T6, T[] T7, T[] T8, T[] T9) where T : INumber<T>
=> [.. container, .. T1, .. T2, .. T3, .. T4, .. T5, .. T6, .. T7, .. T8, .. T9];
public static T[] Merge<T>(this T[] container, T[] T1, T[] T2, T[] T3, T[] T4, T[] T5, T[] T6, T[] T7, T[] T8, T[] T9, T[] T10) where T : INumber<T>
=> [.. container, .. T1, .. T2, .. T3, .. T4, .. T5, .. T6, .. T7, .. T8, .. T9, .. T10];
public static List<T> Merge<T>(this List<T> container, T[] T1) where T : INumber<T>
=> [.. container, .. T1];
public static List<T> Merge<T>(this List<T> container, T[] T1, T[] T2) where T : INumber<T>
=> [.. container, .. T1, .. T2];
public static List<T> Merge<T>(this List<T> container, T[] T1, T[] T2, T[] T3) where T : INumber<T>
=> [.. container, .. T1, .. T2, .. T3];
public static List<T> Merge<T>(this List<T> container, T[] T1, T[] T2, T[] T3, T[] T4) where T : INumber<T>
=> [.. container, .. T1, .. T2, .. T3, .. T4];
public static List<T> Merge<T>(this List<T> container, T[] T1, T[] T2, T[] T3, T[] T4, T[] T5) where T : INumber<T>
=> [.. container, .. T1, .. T2, .. T3, .. T4, .. T5];
public static List<T> Merge<T>(this List<T> container, T[] T1, T[] T2, T[] T3, T[] T4, T[] T5, T[] T6) where T : INumber<T>
=> [.. container, .. T1, .. T2, .. T3, .. T4, .. T5, .. T6];
public static List<T> Merge<T>(this List<T> container, T[] T1, T[] T2, T[] T3, T[] T4, T[] T5, T[] T6, T[] T7) where T : INumber<T>
=> [.. container, .. T1, .. T2, .. T3, .. T4, .. T5, .. T6, .. T7];
public static List<T> Merge<T>(this List<T> container, T[] T1, T[] T2, T[] T3, T[] T4, T[] T5, T[] T6, T[] T7, T[] T8) where T : INumber<T>
=> [.. container, .. T1, .. T2, .. T3, .. T4, .. T5, .. T6, .. T7, .. T8];
public static List<T> Merge<T>(this List<T> container, T[] T1, T[] T2, T[] T3, T[] T4, T[] T5, T[] T6, T[] T7, T[] T8, T[] T9) where T : INumber<T>
=> [.. container, .. T1, .. T2, .. T3, .. T4, .. T5, .. T6, .. T7, .. T8, .. T9];
public static List<T> Merge<T>(this List<T> container, T[] T1, T[] T2, T[] T3, T[] T4, T[] T5, T[] T6, T[] T7, T[] T8, T[] T9, T[] T10) where T : INumber<T>
=> [.. container, .. T1, .. T2, .. T3, .. T4, .. T5, .. T6, .. T7, .. T8, .. T9, .. T10];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment