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
// c-sar-cipher | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdio.h> | |
//#include "c-sar-cipher.h" | |
void run(char* arg, void (*cout)(char*)); | |
void print_string(char* str); | |
char* apply_cipher(char* input); |
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
// Program.h | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
typedef int (*op_on_triple_ptr)(int, int, int); | |
typedef int (*op_on_pair_ptr)(int, int); | |
typedef int (*op_on_single_ptr)(int); | |
void cout_for_op(char* op_name, int op_result); |
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
#!/usr/bin/sh | |
echo $(pwd)$(echo $0 | sed -r 's/^\.(\/[a-zA-Z]+[\.[a-z]*]?)$/\1/g') $1 $2 $3 $4 $5 $6 $7 $8 $9 | |
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; | |
App.Run(args, Console.WriteLine); | |
interface ICipherService | |
{ | |
string Apply(string input, bool encrypt = false); | |
} | |
class XOrCipherService : ICipherService |
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 CaesarCipher; | |
if (args?.Length > 0) | |
Console.WriteLine(args[0].Rot13()); | |
else | |
{ | |
Console.WriteLine("Start typing (Return key to exit)"); | |
PresentUntilReturnKey(); | |
} |
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 Unit = System.ValueTuple; | |
_ = App.Run(Console.WriteLine); | |
static class App | |
{ | |
public static Unit Run(Action<string> outputter) | |
{ | |
outputter(GetAwayWins().ToSummary()); | |
return Unit.Create(); |
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
/* | |
* Trying to emulate the following Haskell, with the aim of demonstrating | |
* that the map function in C# is the Select in Linq... | |
* | |
* main = do | |
* print (reverseEach ["map", "select"]) | |
* | |
* reverseEach l = map reverse l | |
* | |
*/ |
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
namespace MonadFun; | |
// | |
// Inspired by Mikhail Shilkov's blog https://mikhail.io/2016/01/monads-explained-in-csharp/ | |
// | |
public class Maybe<T> : IEquatable<Maybe<T>> | |
where T : class? | |
{ | |
private readonly T? _value; | |
private Maybe() {} |
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
var needles = new List<string> { "b", "d" }; | |
var haystack = new Dictionary<string, object> | |
{ | |
{ "a", 1 }, | |
{ "b", 2 }, | |
{ "c", false }, | |
{ "d", "test" } | |
}; |
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
// Full credit to Nick Chapsas - See: https://youtu.be/jmmz1cInNow | |
foreach (var i in 0..5) | |
{ | |
Console.WriteLine(i); | |
} | |
public static class Extensions | |
{ | |
public static CustomIntEnumerator GetEnumerator(this Range range) => new CustomIntEnumerator(range); |