Skip to content

Instantly share code, notes, and snippets.

ANDREW LONG-TERM TO-DO LIST (DRAFT, FEB 2016)

this is a cleaned-up version of a list i've been adding to for the past several years. i'm not a huge fan of it, because it leaves out the MOST IMPORTANT life to-do: have a successful and productive career (and family). almost everything on this list ("climb mt. rainier!") is secondary to that. too much of this list is about ME (it's things I want). but my life isn't about me. my life is (or ought to be) about things greater than me. i want to (and ought to) devote myself to things outside of myself.

a lot of the items are really specific ("make kimchi") and others more general; some of these are straightforward ("make kimchi") and others a lot harder ("be less self-centered").

i intend this to be a malleable document, but i want to have a cleaned-up, date-stamped draft, representing a reasonable facsimile of what's on my mind right now.

BOOKS

NEVER WRITE A FOR LOOP AGAIN

or, fun folding with map/reduce/filter

andrew alexander

(This is a loose transcription (in some parts, an expansion) of a five-minute talk I gave at the Recurse Center on February 18th, 2016. All of the code I live-coded, so the written version loses some of the pedagological power of narrating my thought process as I type. The code below happens to be JavaScript, but most languages have equivalents.)

@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) ) )
@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.

"""
this is a set of scripts that have evolved over the years to make life easier with my fliphone
my LG VX8150 lets you download all of your contacts to your computer as vCard (.vcf) files
and these scripts can parse them and save them into a variety of convenient formats
"""
def loadContactsFromPhone():
"""
no, just kidding. there doesn't seem to be an easy way to automate the phone-> computer contacts transfer
here are my manual steps
-- can we have a triply palindromic bill???
-- i.e., a bill where the subtotal, the tip, and the total are all numeric palindromes?
-- (note that we're doing all these calculations in cents)
isPalindrome :: Eq a => [a] -> Bool
isPalindrome x = x == reverse x
numToDigits n = map (\x -> read [x] :: Int) (show n)
the right subtotals and the right tips to make a triply-palindromic bill!
subtotal: $0.01; tip: $0.00; total: $0.01
subtotal: $0.02; tip: $0.00; total: $0.02
subtotal: $0.03; tip: $0.00; total: $0.03
subtotal: $0.03; tip: $0.01; total: $0.04
subtotal: $0.04; tip: $0.00; total: $0.04
subtotal: $0.04; tip: $0.01; total: $0.05
subtotal: $0.05; tip: $0.00; total: $0.05
subtotal: $0.05; tip: $0.02; total: $0.07

books, movies poems

the results of an informal facebook poll, taken 7 october 2016:

hey facebook. tell me 1) a book i should read, 2) a movie i should watch, 3) a poem i should memorize.


books

  • Confederacy of Dunces
  • Beloved
  • The Emperor of All Maladies

notes on david rockefeller’s memoirs 27 september 2016

i’ve devoured the MEMOIRS (2002) of david rockefeller, john d.’s grandson, over the last two days. to my surprise, it’s really, really good. it’s well-written, it’s honest, and it’s interesting.

david––born in 1915 and still alive––grew up in new york, went to harvard, served in world war two, and worked at chase manhattan for 30 years, ultimately as chairman.


rockefeller writes about his insecurities as a young man, about his wife’s depression, and about his father’s lifelong struggles with insecurity, introversion, and depression. he talks about his own failures as a parent. for a book whose tone is very even, steady, and unemotional, i am impressed at how much of this personal, emotional stuff he reveals.

CANADIAN CITIZENSHIP NOTES

APRIL 2017

PART ONE: AM I A CANADIAN CITIZEN??

  • canada revised its (already very complex) citizenship laws in 2009. at the time i thought there was a high probability that it might mean i was a canadian citizen, and almost wrote a column for the chicago maroon about it. i ended up spiking the column for other reasons, and, on further investigation, decided that the law didn't actually apply to me.

  • last year sarah somehow heard about this, and decided that it applied to her, and decided she would apply to "resume" her canadian citizenship. i re-read the citizenship laws, and was still fairly certain that it didn't apply to her (and thus, recursively, to me).