Skip to content

Instantly share code, notes, and snippets.

Interactive Elixir (1.1.0-dev) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> list = [1, 2, 3]
[1, 2, 3]
iex(2)> new_list = [ 0 | list ]
[0, 1, 2, 3]
iex(3)> [ head | tail ] = new_list
[0, 1, 2, 3]
iex(4)> head
0
defmodule MyApp do
def clean_string(str), do: String.codepoints(str) |> _clean([])
defp _clean([], result) do
result
|> Enum.reverse
|> to_string
end
defp _clean([h | t], result) do
# lib/my_app.ex
defmodule MyApp do
import MyApp.Blah
def foo do
# because we imported it, we can call the `bar` function directly
bar
end
end

>For the remaining kanji, you have the god Fudo (不動), whose name translates literally as “unmovable.” He is a particularly cool god. Fudo looks like an oni with his fierce visage, proudly upheld sword, and flaming throne. There’s really too much to be said about Fudo to go into it here, but suffice it to say if you were going to pick a god to defend your city in a magical circle of protection, Fudo is a good god to gamble on.

(add-to-list 'load-path "~/.emacs.d/community")
(add-to-list 'load-path "~/.emacs.d/community/powerline")
(add-to-list 'load-path "~/.emacs.d/community/tester.el")
;; Behavior
;; disable the splash screen
(setq inhibit-splash-screen t)
(when (not (display-graphic-p))
iex(3)> foo = [{:a, :b}]
[a: :b]
iex(4)> bar = {:b, :a}
{:b, :a}
iex(5)> [bar|foo]
[b: :a, a: :b]
#!/bin/sh
/Applications/Emacs.app/Contents/MacOS/Emacs "$@"
(add-to-list 'load-path "~/.emacs.d/community")
(add-to-list 'load-path "~/.emacs.d/community/powerline")
(add-to-list 'load-path "~/.emacs.d/community/tester.el")
;; Behavior
;; disable the splash screen
(setq inhibit-splash-screen t)
(when (not (display-graphic-p))
defmodule Recursive do
def naive_fac(0), do: 1
def naive_fac(n) when n > 0, do: n * naive_fac(n - 1)
def tail_fac(n), do: _tail_fac(n,1)
defp _tail_fac(0, acc), do: acc
defp _tail_fac(n, acc), do: _tail_fac(n - 1, n*acc)
def naive_len([]), do: 0
def naive_len([_|t]), do: 1 + naive_len(t)
@edubkendo
edubkendo / indent.ex
Created December 24, 2014 09:57
Emacs elixir-mode indenting still not quite right...
defmodule IndentPlayground do
def my_func(arr) do
Enum.map(arr, fn(x) ->
x * 2
end)
#back here
end
end