Skip to content

Instantly share code, notes, and snippets.

View seanparsons's full-sized avatar
💭
Setting A Status Message

Sean Parsons seanparsons

💭
Setting A Status Message
View GitHub Profile
@seanparsons
seanparsons / gist:4e4692ca01c65413cd88
Created September 4, 2015 14:26
Function definition example in Haskell.
doubleUs Int -> Int -> Int
doubleUs 0 0 = 0
doubleUs a 0 = a * 2
doubleUs 0 b = b * 2
doubleUs x y = x * 2 + y * 2
@seanparsons
seanparsons / gist:83d37b13e60d1065eb22
Created September 18, 2015 16:28
Chef Goldfarb's Keto Chicken Pizza
Package of ground organic chicken, half bunch of kale, walnuts, 1 onion, 1 clove garlic, gorgonzola.
Mix w hands till well blended. add salt, pepper, red pepper flakes.
Spread out on either parchment or pie platepat flat, maybe 3/4 inch to 1/2 inch max.
Top pizza w Gorgonzola or other strong cheese (taleggio wd work) and other half onion, diced.
Preheat oven to 180 C, in it goes after, raise to 220c for 12 minutes..then lower to 180.
There will be a layer of fat and water from kale - remove pizza and pour off, then replace and bake 5 more min with crushed walnuts.
Remove from heat. let it cool. Consume.
Can even top w sour cream/creme fraiche/smetana.
case ShotFired(by, atX, atY) => by + " fired at (" + atX + "," + atY + ")"
case class MedikitUsed(val name: String, val useAmount: Int)
val result = new MedikitUsed("Sean", 0) match {
case MedikitUsed(name, 0) => name + " attempted to use none of their medikit and that makes no sense."
}
abstract class SpecialWeapon
case class SpecialWeaponUsed(val player: String, val weapon: SpecialWeapon)
case class NuclearBomb(val megatons: Int) extends SpecialWeapon
val result = new SpecialWeaponUsed("Sean", new NuclearBomb(17)) match {
case SpecialWeaponUsed(name, NuclearBomb(megatons)) => name + " used a " + megatons + " megaton nuclear bomb."
}
String intMatch(int number) {
switch (number) {
case 1: return "This is number 1.";
case 2: return "This is number 2, it comes after 1.";
default: return "This number is neither 1 nor 2.";
}
}
def intMatch(number: Int): String = {
return number match {
case 1 => "This is number 1."
case 2 => "This is number 2, it comes after 1."
case _ => "This number is neither 1 nor 2."
}
}
def anyMatch(something: Any): String = {
return something match {
case text: String => text
case number: Int => "This is the number " + number + "."
case _ => "Unknown thing."
}
}
def positiveIntMatch(number: Int): String = {
return number match {
case positive: Int if positive >= 0 => positive + " is greater than or equal to zero."
case negative: Int => negative + " is less than zero."
}
}
case class ShotFired(val playerName: String, val atX: Int, val y: Int)
val result = new ShotFired("Sean", 2, 5) match {
case ShotFired(by, atX, atY) => by + " fired at (" + atX + "," + atY + ")"
}