Skip to content

Instantly share code, notes, and snippets.

View aaron-price's full-sized avatar

Aaron aaron-price

  • Vancouver
View GitHub Profile
@aaron-price
aaron-price / naive_put_in.ex
Created June 16, 2021 01:26
naive_put_in.ex
defmodule NaivePutIn do
@doc """
### What problem does this solve?
Sometimes I need a deeply nested map. Maps ALL THE WAY DOWN!
If I can safely assume every step is a map, I should be able to do this:
iex(0)> put_in(%{}, [:a, :b, :c], "V")
(ns random-roll)
; My friends: "Let's play this stupid game over zoom. Everyone needs some dice"
; Me 10 minutes later:
(defn single-roll [sides]
(inc (rand-int sides)))
(defn roll