Skip to content

Instantly share code, notes, and snippets.

View goofballLogic's full-sized avatar
👔
Still counting things

Andrew Stewart Gibson goofballLogic

👔
Still counting things
  • 15:15 (UTC +01:00)
View GitHub Profile
// Set up:
// - dotnet new console
// - dotnet add package OneOf
// Implement each of the methods below so that they all compile
// There only one valid implementation for each function (apart from f5 & f6)
using OneOf;
A F1<A>(A a) {
class Cat {
speak() { return "meow"; }
}
function process(cat) {
return cat.speak();
}
class Ball {
}
terraform {
required_version = ">= 0.12"
}
provider "aws" {
region = "eu-west-1"
}
resource "aws_instance" "web" {
const ordinalSuffixes = {
"en": {
"one": "st",
"two": "nd",
"few": "rd",
"other": "th"
}
};
export class OrdinalFormat {
import { OrdinalFormat } from "./ordinal-formatting.js";
const fullFormat = new Intl.DateTimeFormat("en", { dateStyle: "full" });
const now = new Date();
const parts = fullFormat.formatToParts(now);
const weekDayName = parts.find(p => p.type === "weekday").value;
const dayName = parts.find(p => p.type === "day").value;
const fullFormat = new Intl.DateTimeFormat("en", { dateStyle: "full" });
const ordinalSuffixes = {
"one": "st",
"two": "nd",
"few": "rd",
"other": "th"
};
const ordinalPluralRules = new Intl.PluralRules("en", { type: "ordinal" });
const ordinalSuffixes = {
"one": "st",
"two": "nd",
"few": "rd",
"other": "th"
};
const ordinalPluralRules = new Intl.PluralRules("en", { type: "ordinal" });
function withOrdinalSuffix(x) {
const ordinalSuffixes = {
"one": "st",
"two": "nd",
"few": "rd",
"other": "th"
};
const ordinalPluralRules = new Intl.PluralRules("en", { type: "ordinal" });
const ordinal = ordinalPluralRules.select(3);
const cardinalPluralRules = new Intl.PluralRules("en");
cardinalPluralRules.select(0) // other
cardinalPluralRules.select(1) // one
cardinalPluralRules.select(2) // other
cardinalPluralRules.select(3) // other
cardinalPluralRules.select(4) // other
const ordinalPluralRules = new Intl.PluralRules("en", { type: "ordinal" });
ordinalPluralRules.select(0) // other
ordinalPluralRules.select(1) // one
const fullFormat = new Intl.DateTimeFormat("en", { dateStyle: "full" });
const now = new Date();
fullFormat.format(now);
// Thursday, October 28, 2021
fullFormat.formatToParts(now)
/*
[
{