- Get some help:
iex> i 'hello'
Term
defmodule Math do | |
def zero?(0) do | |
true | |
end | |
def zero?(x) when is_integer(x) do | |
false | |
end | |
end |
defmodule Recursion do | |
def print_multiple_times(msg, n) when n <= 1 do | |
IO.puts msg | |
end | |
def print_multiple_times(msg, n) do | |
IO.puts msg | |
print_multiple_times(msg, n - 1) | |
end | |
end |
defmodule Math do | |
def sum_list([head | tail], accumulator) do | |
sum_list(tail, head + accumulator) | |
end | |
def sum_list([], accumulator) do | |
accumulator | |
end | |
end |
:: Elixir study notes. | |
# get some help: | |
iex> i 'hello' | |
Term | |
'hello' | |
Data type | |
List | |
Description | |
... |
iex> i 'hello'
Term
def print_msg_n_times(msg, n) | |
n.times do | |
puts msg | |
end | |
end | |
print_msg_n_times('Hello world', 6_000) |
defmodule Math do | |
def sum_list(list, accumulator \\ 0) | |
def sum_list([head | tail], accumulator) do | |
sum_list(tail, head + accumulator) | |
end | |
def sum_list([], accumulator) do | |
accumulator | |
end |
defmodule Triple do | |
def pythagorean(n) when n > 0 do | |
for a <- 1..n, | |
b <- 1..n, | |
c <- 1..n, | |
do: IO.puts "#{a} #{b} #{c}" | |
end | |
end | |
Triple.pythagorean(10) |
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" | |
if [[ $UID -eq 0 ]]; then | |
local user_host='%{$terminfo[bold]$fg[red]%}%n@%m%{$reset_color%}' | |
local user_symbol='#' | |
else | |
local user_host='%{$terminfo[bold]$fg[grey]%}%n@%m%{$reset_color%}' | |
local user_symbol='$' | |
fi |
I hereby claim:
To claim this, I am signing this object: