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
----------------------------- MODULE Liverpool ----------------------------- | |
EXTENDS Naturals, FiniteSets, Integers | |
VARIABLES discard, stock, players, player_score, round, player_hand, top_discard, player_goal_state | |
Bool == { TRUE, FALSE } | |
Rank == 1..14 | |
Suite == { "H", "S", "C", "D" } |
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; | |
using System.Linq; | |
using System.Threading; | |
using System.Net.Sockets; | |
using System.Collections.Generic; | |
using System.Runtime.CompilerServices; | |
public class C | |
{ | |
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
public abstract class Maybe<T> | |
{ | |
public abstract T Value { get; } | |
public virtual string Failure => null; | |
public Maybe<V> SelectMany<U, V>(Func<T, Maybe<U>> f, Func<T, U, V> g) | |
{ | |
var that = f(this.Value); |
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
create table Calendar | |
( | |
id int primary key identity, | |
date datetime unique not null, | |
day_of_week as datepart(dw, date), | |
month as datepart(month, date), | |
day_name as datename(dw, date), | |
year as datepart(year, date), | |
day_of_month as datepart(day, date), | |
week as datepart(week, date), |
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
begin tran | |
create table Calendar | |
( | |
id int primary key identity, | |
date datetime not null | |
) | |
declare @dt datetime | |
set @dt = '1/1/2017' |
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
set xact_abort on | |
begin tran | |
create table Calendar | |
( | |
id int primary key identity, | |
[date] datetime, | |
[day] as datepart(day, [date]) persisted, | |
[month] as datepart(month, [date]) persisted, |
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; | |
using System.Collections.Generic; | |
namespace FizzBuzz | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
FizzBuzz(0); |
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
static class RegexUtil | |
{ | |
static readonly memo = new Dictionary<string, Regex>(); | |
public static bool IsMatch(this string s, RegexOptions? options = null) | |
{ | |
if(!memo.TryGetValue(s, out RegEx rgx)) | |
memo.Add(s, rgx = new RegEx(s, options ?? RegExOptions.None)); | |
return rgx.IsMatch(s); |
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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var buffy = new Person("Buffy Summers", DateTime.Parse("1/19/1981")); | |
var xander = new Person("Xander Harris", DateTime.Parse("5/2/1981")); | |
var willow = new Person("Willow Rosenberg", DateTime.Parse("12/3/1980")); | |
var oldest = OrderModule<Person>.Max(buffy, xander, willow); | |
} |
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 Prelude | |
{ | |
public static class Utils | |
{ | |
public struct RetrievedValue<T> | |
{ | |
readonly T value; | |
readonly string failed; | |
internal RetrievedValue(T value, string failed) |
NewerOlder