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 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) { |
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 Cat { | |
speak() { return "meow"; } | |
} | |
function process(cat) { | |
return cat.speak(); | |
} | |
class Ball { | |
} |
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
terraform { | |
required_version = ">= 0.12" | |
} | |
provider "aws" { | |
region = "eu-west-1" | |
} | |
resource "aws_instance" "web" { |
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
const ordinalSuffixes = { | |
"en": { | |
"one": "st", | |
"two": "nd", | |
"few": "rd", | |
"other": "th" | |
} | |
}; | |
export class OrdinalFormat { |
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
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; |
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
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" }); |
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
const ordinalSuffixes = { | |
"one": "st", | |
"two": "nd", | |
"few": "rd", | |
"other": "th" | |
}; | |
const ordinalPluralRules = new Intl.PluralRules("en", { type: "ordinal" }); | |
function withOrdinalSuffix(x) { |
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
const ordinalSuffixes = { | |
"one": "st", | |
"two": "nd", | |
"few": "rd", | |
"other": "th" | |
}; | |
const ordinalPluralRules = new Intl.PluralRules("en", { type: "ordinal" }); | |
const ordinal = ordinalPluralRules.select(3); |
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
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 |
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
const fullFormat = new Intl.DateTimeFormat("en", { dateStyle: "full" }); | |
const now = new Date(); | |
fullFormat.format(now); | |
// Thursday, October 28, 2021 | |
fullFormat.formatToParts(now) | |
/* | |
[ | |
{ |
NewerOlder