summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkballou <kballou@devnulllabs.io>2016-03-18 23:16:28 -0600
committerkballou <kballou@devnulllabs.io>2016-03-18 23:16:28 -0600
commitf6dbc3e24ae3aaccc2c2485441dca56e029b4ad5 (patch)
treef47b0eb607bbdb52d9baad36b2ba8c82d6416e4e
parentd7b08881034cb4ad72572fd167ae077d19ffebc9 (diff)
downloadfunc-w-elixir-f6dbc3e24ae3aaccc2c2485441dca56e029b4ad5.tar.gz
func-w-elixir-f6dbc3e24ae3aaccc2c2485441dca56e029b4ad5.tar.xz
Simplify syntax slides
We don't need to spend this much time on the basic syntax. Most of it can be read online or picked up along the way.
-rw-r--r--src/code/1/atoms17
-rw-r--r--src/code/1/binaries13
-rw-r--r--src/code/1/booleans19
-rw-r--r--src/code/1/essentials43
-rw-r--r--src/code/1/functions14
-rw-r--r--src/code/1/helloworld6
-rw-r--r--src/code/1/lists21
-rw-r--r--src/code/1/maps23
-rw-r--r--src/code/1/numbers29
-rw-r--r--src/code/1/tuples17
-rw-r--r--src/func-w-elixir.tex86
11 files changed, 60 insertions, 228 deletions
diff --git a/src/code/1/atoms b/src/code/1/atoms
deleted file mode 100644
index fe6b2b8..0000000
--- a/src/code/1/atoms
+++ /dev/null
@@ -1,17 +0,0 @@
-iex> :atom
-:atom
-iex> :ok
-:ok
-iex> :error
-:error
-iex> Foobar
-Foobar
-iex> :this_is_a_long_atom_dont_do_this
-:this_is_a_long_atom_dont_do_this
-
-iex> Atom.to_string :foo
-"foo"
-iex> String.to_atom "foo"
-:foo
-iex> String.to_atom "foo with a space and bar"
-:"foo with a space and bar"
diff --git a/src/code/1/binaries b/src/code/1/binaries
deleted file mode 100644
index 1ac8fbf..0000000
--- a/src/code/1/binaries
+++ /dev/null
@@ -1,13 +0,0 @@
-iex> <<1, 2, 3>>
-<<1, 2, 3>>
-iex> <<255, 255, 256>>
-<<255, 255, 0>>
-iex> <<256 :: size(16)>>
-<<1, 0>>
-iex> <<"Hello, 世界" :: utf8>>
-"Hello, 世界"
-
-iex> <<1, 2>> <> <<3>>
-<<1, 2, 3>>
-iex> "Hello, " <> "World"
-"Hello, World"
diff --git a/src/code/1/booleans b/src/code/1/booleans
deleted file mode 100644
index 6540097..0000000
--- a/src/code/1/booleans
+++ /dev/null
@@ -1,19 +0,0 @@
-iex> true
-true
-iex> false
-false
-iex> not false
-true
-
-iex> true or false
-true
-iex> true and false
-false
-iex> false || 13
-13
-iex> true && 42
-42
-iex> true == true
-true
-iex> true != false
-true
diff --git a/src/code/1/essentials b/src/code/1/essentials
new file mode 100644
index 0000000..ea7b29a
--- /dev/null
+++ b/src/code/1/essentials
@@ -0,0 +1,43 @@
+iex> 42
+42
+iex> :ok
+:ok
+iex> [1, 2, 3, 4]
+[1, 2, 3, 4]
+iex> {:reply, 42}
+{:reply, 42}
+iex> 'hello, world'
+'hello, world'
+iex> [104, 101, 108, 108, 111]
+'hello'
+iex> 'こにちは、世界'
+[12371, 12395, 12385, 12399, 12289, 19990, 30028]
+iex> "Hello, 世界"
+"Hello, 世界"
+iex> <<"Hello, 世界" :: utf8>>
+"Hello, 世界"
+
+iex> %{}
+%{}
+iex> %{a: 1, b: 2}
+%{a: 1, b: 2}
+iex> defmodule Person do
+...> defstruct name: nil, age: 0, height: 0
+...> end
+iex> %Person{name: "Kenny Ballou", age: 24, height: 177}
+%Person{name: "Kenny Ballou", age: 24, height: 177}
+
+iex> f = fn(x) -> x * x end
+#Function<6.54118792/1 in :erl_eval.expr/5>
+iex> f.(2)
+4
+iex> defmodule Foobar do
+...> def foo(x), do: x * 2
+...> def bar(y) do
+...> y |> foo() |> (&*/2).(3)
+...> end
+...> end
+iex> Foobar.foo(5)
+10
+iex> Foobar.bar(2)
+12
diff --git a/src/code/1/functions b/src/code/1/functions
deleted file mode 100644
index 03559ad..0000000
--- a/src/code/1/functions
+++ /dev/null
@@ -1,14 +0,0 @@
-iex> f = fn(x) -> x * x end
-#Function<6.54118792/1 in :erl_eval.expr/5>
-iex> f.(2)
-4
-iex> g = &(&1 * &1)
-#Function<6.54118792/1 in :erl_eval.expr/5>
-iex> h = fn(x) -> x + 1 end
-#Function<6.54118792/1 in :erl_eval.expr/5>
-iex> f.(2)
-4
-iex> g.(2)
-4
-iex> h.(1)
-2
diff --git a/src/code/1/helloworld b/src/code/1/helloworld
new file mode 100644
index 0000000..eec73a1
--- /dev/null
+++ b/src/code/1/helloworld
@@ -0,0 +1,6 @@
+iex> "hello, world"
+"hello, world"
+
+iex> IO.puts "hello, world"
+hello, world
+:ok
diff --git a/src/code/1/lists b/src/code/1/lists
deleted file mode 100644
index 836d30b..0000000
--- a/src/code/1/lists
+++ /dev/null
@@ -1,21 +0,0 @@
-iex> []
-[]
-iex> [1, 2, 3,]
-[1, 2, 3]
-iex> [1, :a, ['b']]
-[1, :a, ['b']]
-iex> [104, 101, 108, 108, 111]
-'hello'
-iex> 'hełło'
-'hełło'
-iex> 'こにちは、世界'
-[12371, 12395, 12385, 12399, 12289, 19990, 30028]
-
-iex> hd([1, 2, 3,])
-1
-iex> tl([1, 2, 3])
-[2, 3]
-iex> [1] ++ [2, 3]
-[1, 2, 3]
-iex> [1, 2, 3] -- [1]
-[2, 3]
diff --git a/src/code/1/maps b/src/code/1/maps
deleted file mode 100644
index 224af0e..0000000
--- a/src/code/1/maps
+++ /dev/null
@@ -1,23 +0,0 @@
-iex> %{}
-%{}
-iex> %{"key" => "value"}
-%{"key" => "value"}
-iex> %{a: 2, b: 1}
-%{a: 2, b: 1}
-iex> [{:a, 2}, {:b, 1}]
-[a: 2, b: 1]
-iex> [a: 2, b: 1]
-[a: 2, b: 1]
-
-iex> my_map = %{a: 2, b: 1}
-%{a: 2, b: 1}
-iex> my_map[:a]
-2
-iex> Map.get(my_map, :a)
-2
-iex> my_map.a
-2
-iex> Map.put(my_map, :c, 4)
-%{a: 2, b: 1, c: 4}
-iex> Map.put(my_map, :a, 42)
-%{a: 42, b: 1}
diff --git a/src/code/1/numbers b/src/code/1/numbers
deleted file mode 100644
index d13d948..0000000
--- a/src/code/1/numbers
+++ /dev/null
@@ -1,29 +0,0 @@
-iex> 42
-42
-iex> -42
--42
-iex> 0
-0
-iex> 1.0
-1.0
-iex> 6.674e-11
-6.674e-11
-iex> 0b1010
-10
-iex> 0o755
-493
-iex> 0xFF
-255
-
-iex> 0 + 1
-1
-iex> 6 * 7
-42
-iex> 2 - 4
--2
-iex> 1/3
-0.3333333333333333
-iex> div(1, 3)
-0
-iex> rem(1, 3)
-1
diff --git a/src/code/1/tuples b/src/code/1/tuples
deleted file mode 100644
index 60c5d52..0000000
--- a/src/code/1/tuples
+++ /dev/null
@@ -1,17 +0,0 @@
-iex> {}
-{}
-iex> {1, 2, 3}
-{1, 2, 3}
-iex> {1, :a, 3}
-{1, :a, 3}
-
-iex> tuple_size {1, 2, 3}
-3
-iex> elem({1, 2, 3}, 1)
-2
-iex> tuple = {:ok, 'hello'}
-{:ok, 'hello'}
-iex> put_elem(tuple, 1, 'world'}
-{:ok, 'world'}
-iex> tuple
-{:ok, 'hello'}
diff --git a/src/func-w-elixir.tex b/src/func-w-elixir.tex
index 476045b..e10934c 100644
--- a/src/func-w-elixir.tex
+++ b/src/func-w-elixir.tex
@@ -146,95 +146,31 @@ in 1986}
\end{frame}
\begin{frame}[fragile]
-\frametitle{Basic Types}
-\framesubtitle{Numerals}
-\lstinputlisting[lastline=16]{code/1/numbers}
+\frametitle{Hello, World}
+\lstinputlisting[lastline=2]{code/1/helloworld}
\end{frame}
\begin{frame}[fragile]
-\frametitle{Basic types}
-\framesubtitle{Numeral Operators}
-\lstinputlisting[firstline=18]{code/1/numbers}
+\frametitle{Hello, World}
+\lstinputlisting[firstline=4]{code/1/helloworld}
\end{frame}
\begin{frame}[fragile]
-\frametitle{Basic Types}
-\framesubtitle{Atoms}
-\lstinputlisting[lastline=10]{code/1/atoms}
+\frametitle{Elixir\texttt{|>} Essentials}
+\lstinputlisting[lastline=18]{code/1/essentials}
\end{frame}
\begin{frame}[fragile]
-\frametitle{Basic Types}
-\framesubtitle{Atom Functions}
-\lstinputlisting[firstline=12]{code/1/atoms}
+\frametitle{Elixir\texttt{|>} Essentials}
+\lstinputlisting[firstline=20,lastline=28]{code/1/essentials}
\end{frame}
\begin{frame}[fragile]
-\frametitle{Basic Types}
-\framesubtitle{Booleans}
-\lstinputlisting[lastline=6]{code/1/booleans}
-\end{frame}
-
-\begin{frame}[fragile]
-\frametitle{Basic Types}
-\framesubtitle{Boolean Operators}
-\lstinputlisting[firstline=8]{code/1/booleans}
-\end{frame}
-
-\begin{frame}[fragile]
-\frametitle{Basic Types}
-\framesubtitle{Lists}
-\lstinputlisting[lastline=12]{code/1/lists}
-\end{frame}
-
-\begin{frame}[fragile]
-\frametitle{Basic Types}
-\framesubtitle{List Operations}
-\lstinputlisting[firstline=14]{code/1/lists}
-\end{frame}
-
-\begin{frame}[fragile]
-\frametitle{Basic Types}
-\framesubtitle{Tuples}
-\lstinputlisting[lastline=6]{code/1/tuples}
-\end{frame}
-
-\begin{frame}[fragile]
-\frametitle{Basic Types}
-\framesubtitle{Tuple Operations}
-\lstinputlisting[firstline=8]{code/1/tuples}
-\end{frame}
-
-\begin{frame}[fragile]
-\frametitle{Basic Types}
-\framesubtitle{Binaries}
-\lstinputlisting[lastline=8]{code/1/binaries}
-\end{frame}
-
-\begin{frame}[fragile]
-\frametitle{Basic Types}
-\framesubtitle{Binary Operations}
-\lstinputlisting[firstline=10]{code/1/binaries}
-\end{frame}
-
-\begin{frame}[fragile]
-\frametitle{Basic Types}
-\framesubtitle{Maps}
-\lstinputlisting[lastline=10]{code/1/maps}
-\end{frame}
-
-\begin{frame}[fragile]
-\frametitle{Basic Types}
-\framesubtitle{Map Operations}
-\lstinputlisting[firstline=12]{code/1/maps}
-\end{frame}
-
-\begin{frame}[fragile]
-\frametitle{Basic Types}
-\framesubtitle{Functions}
-\lstinputlisting{code/1/functions}
+\frametitle{Elixir\texttt{|>} Essentials}
+\lstinputlisting[firstline=30]{code/1/essentials}
\end{frame}
+\subsection{General Concepts}
\begin{frame}
\frametitle{Dispelling Assignment}
\framesubtitle{There is no spoon}