Skip to content

Instantly share code, notes, and snippets.

@steven2358
steven2358 / ffmpeg.md
Last active September 10, 2024 15:11
FFmpeg cheat sheet
@amalex5
amalex5 / ThreeFunThingsAboutHaskell.md
Last active March 21, 2018 19:08
Three Fun Things About Haskell

Three Fun Things About Haskell

###Andrew Alexander

A loose transcription of an impromptu five-minute presentation at the Recurse Center, 5 May 2016

##Pattern-matching

(I don't think "pattern matching" is a great name, but this is what everyone calls it.) Anyway, in normal programming, you define a function exactly ONCE, and if you need it to behave differently depending on what its input is, you have to write if-then branches or switch or case statements, and things can get very ugly very fast.

@amalex5
amalex5 / symdiff.hs
Created March 31, 2016 18:06
symbolic differentiation is SO EASY in haskell!
-- i mean, this is basically just a high school formula sheet
-- that happens to also be valid haskell
-- (we're differentiating against "Symbol")
diff (Symbol) = Val 1
diff (Neg x) = Neg (diff x)
diff (Add x y) = Add (diff x) (diff y)
diff (Mul x y) = Add (Mul (diff x) y ) (Mul x (diff y))
diff (Sub x y) = diff (Add x (Neg y))
diff (Pow x (Val n)) = Mul (Val n) (Pow x (Val (n - 1) ) )