This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use crossterm::{ | |
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode}, | |
execute, | |
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, | |
}; | |
use std::{ | |
error::Error, | |
io, | |
time::{Duration, Instant}, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Text; | |
namespace <SomeNamespace>; | |
public static class AsTextExtension | |
{ | |
public static string AsText<T>(this IEnumerable<T> sequence, string separator = ", ", int numberOfBreak = 50) | |
{ | |
var builder = new StringBuilder(); | |
builder.Append("[ "); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
delegate bool SomePredicate<T>(T a); | |
public List<T> Filter<T>(T[] input, SomePredicate<T> function) | |
{ | |
var newList = new List<T>(); | |
foreach(var element in input) | |
{ | |
if (function(element)) | |
{ | |
newList.Add(element); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal static class Program | |
{ | |
public delegate void DoSomething(); | |
// Compiler created this class in background because of public delegate void DoSomething(). | |
public class DoSomethingDelegate | |
{ | |
private List<DoSomething>? _invocationList = new List<DoSomething>(); | |
public DoSomethingDelegate(DoSomething function) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <vector> | |
/// Precondition: argc and argv were given as parameter for main function | |
/// because the represents the in lines arguments for a program. | |
/// Precondition: argc is the number of elements in argv. | |
/// Note: Returns an empty vector if argc is zero. | |
std::vector<std::string> makeArgsHandy(int argc, char** argv) | |
{ | |
size_t size{static_cast<size_t>(argc)}; | |
std::vector<std::string> converted{size}; |