-- 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 |
-- GIVEN | |
type MyList a | |
= Cons a (MyList a) | |
| Empty | |
add : Int -> Int -> Int | |
add a b = | |
a + b |
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
class EmptyList | |
def prepend(value) | |
List.new(value, self) | |
end | |
def inspect | |
"()" | |
end | |
def map(&block) |
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
There are 6 possible squares that can be made by adding two numbers under 16:
I often write Ellies to demo an idea or to share a solution with someone on Slack. Some of them are helpful enough to share many times so I keep a reference to them here. Others are just cool so I want to save the link 😎
::
is the list prepend operator in Elm.
3 :: 2 :: 1 :: []
is equivalent to
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.
In mutation, the value of an object changes but its identity remains the same: