This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map_1 = %{first: 1, second: 2} | |
map_2 = %{first: 3, second: 4} | |
# These just work! 🤩 | |
Zip.apply(map_1, map_2, Add) #=> %{first: 4, second: 6} | |
Zip.apply(map_1, map_2, Subtract) #=> %{first: 4, second: 6} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// As you might expect | |
func add(x int, y int) int { | |
return x + y | |
} | |
// Go functions can return multiple values though, so you | |
// Can type each of the return values | |
func swap(x, y string) (string, string) { | |
return y, x | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Third round of feature requests | |
# Extend your design to support one of the following two features: | |
# Ability to look up, for all users, how many have a todo item with the same name as one of yours. | |
# Also, explain how to extend your user interface to display the total number of todo items in the | |
# list currently being viewed. This feature is simple, but there are some easy ways to get it wrong. | |
# Ability to go back into the past, and see what a user's todo list looked like at any point in time. | |
# Explain how this would work for todo lists that already exist. | |
# ================================================================================================= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Shape do | |
@callback area(map()) :: integer() | |
@callback perimeter(map()) :: integer() | |
end | |
defmodule Square do | |
defstruct [:side] | |
@behaviour Shape |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A simple Lisp parser. You could copy paste this into iex (the elixir repl) | |
# or use a livebook, and you can run the parser like this: | |
# | |
# Elexer.parse("(+ 1 -2)") | |
# A more fully featured prject can be found here: https://github.com/Adzz/elexer | |
defmodule Elexer do | |
@moduledoc """ | |
A simple lisp parser. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
RED="\033[31m" | |
GREEN="\033[32m" | |
RESET="\033[0m" | |
MAGENTA="\033[35m" | |
CYAN="\033[36m" | |
YELLOW="\033[33m" | |
BLUE="\033[34m" |
OlderNewer