Skip to content

Instantly share code, notes, and snippets.

@BoolPurist
Last active July 2, 2022 17:11
Show Gist options
  • Save BoolPurist/e2a6545bf3c8e0b6e71c61cdac780e66 to your computer and use it in GitHub Desktop.
Save BoolPurist/e2a6545bf3c8e0b6e71c61cdac780e66 to your computer and use it in GitHub Desktop.
delegate T MapperFunction<T>(T number);
// Ruegabewert ist eine Liste genauso lange wie der Parameter arr.
// Die Liste enthaelt alle gemappten Elemente von arr.
// Mappen bedeutet, dass ein Element durch die Funktion Mapper auf einen neuen Wert abgebildet wird.
// Die Liste enthaelt alle neuen gemappten Werte.
static List<T> Map<T>(T[] array, MapperFunction<T> mapper)
{
var list = new List<T>();
foreach (var element in array)
{
list.Add(mapper(element));
}
return list;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment