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
This file contains 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 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 |
This file contains 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
# 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.
This file contains 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
(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)) |
This file contains 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
iex(3)> foo = [{:a, :b}] | |
[a: :b] | |
iex(4)> bar = {:b, :a} | |
{:b, :a} | |
iex(5)> [bar|foo] | |
[b: :a, a: :b] |
This file contains 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/sh | |
/Applications/Emacs.app/Contents/MacOS/Emacs "$@" |
This file contains 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
(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)) |
This file contains 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 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) |
This file contains 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 IndentPlayground do | |
def my_func(arr) do | |
Enum.map(arr, fn(x) -> | |
x * 2 | |
end) | |
#back here | |
end | |
end |