Skip to content

Instantly share code, notes, and snippets.

@JoelQ
JoelQ / elm-decoder-challenge.md
Created June 9, 2018 23:37
Elm Decoder Challenges
@JoelQ
JoelQ / MapZero.elm
Created May 30, 2018 18:08
A look at mapN functions in Elm. The `map0` function is just the constructor function! Haskell folks would call this pure/return.
-- Maybe
map2 f v1 v2 = Just f |> andMap v1 |> andMap v2
map f v1 = Just f |> andMap v1
map0 f = Just f
-- List
map2 f v1 v2 = singleton f |> andMap v1 |> andMap v2
map f v1 = singleton f |> andMap v1
@JoelQ
JoelQ / Folding.elm
Created March 20, 2018 18:44
Folding a list is like replacing the cons and empty constructors
-- GIVEN
type MyList a
= Cons a (MyList a)
| Empty
add : Int -> Int -> Int
add a b =
a + b
@JoelQ
JoelQ / elm-maybe-map-compose.md
Created February 9, 2018 15:52
Refactoring a pipeline of Maybe.map functions in Elm

Refactoring maybe code in Elm

Given this ugly series of cases:

optionalFormattedFriendAddress : Maybe Friend -> Maybe String
optionalFormattedFriendAddress maybeFriend =
  let
    maybeAddress = case maybeFriend of
      Just friend -> Just friend.address

A Darwinian Nightmare

It seemed to have stepped right out of the pages of a horror novel. The mutant shape-shifter struck without warning, defying a mere mortal's attempts to detect it. It seemed to distort the fabric of reality itself. And it was going to ruin my job interview.

We've all encountered this monster at some point. Like many classic monsters, it is our own creation. Every year it devastate projects worldwide. The fearsome mutation bug is an expert at hiding and altering your programs in subtle and

@JoelQ
JoelQ / empty_list.rb
Created January 18, 2018 02:24
Linked-list (cons list) implementation in Ruby
class EmptyList
def prepend(value)
List.new(value, self)
end
def inspect
"()"
end
def map(&block)
@JoelQ
JoelQ / square-sum.md
Last active January 12, 2018 06:07
Attempted solution to the square-sum challenge

Square-Sum Challenge

Write out the numbers 1-15 such that any two numbers in the series add up to a square number

Inspired by https://www.youtube.com/watch?v=G1m7goLCJDY

Possible squares

There are 6 possible squares that can be made by adding two numbers under 16:

@JoelQ
JoelQ / ellie_examples.md
Last active July 28, 2021 14:12
List of helpful Ellie's I've written
@JoelQ
JoelQ / list-pattern-matching-elm.md
Last active December 5, 2021 16:39
What does `x :: xs` pattern matching mean in Elm?

What does x :: xs pattern matching mean in Elm?

:: is the list prepend operator in Elm.

3 :: 2 :: 1 :: []

is equivalent to

Mutation in Ruby

Mutation-related bugs are some of the most common in the Ruby world. Joël and German explore many of the gotchas related to mutation, how to avoid them, and discuss when mutation might not be necessary at all.

Mutation vs Reassignment

In mutation, the value of an object changes but its identity remains the same: