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
[1, 2, 3, 4, 5] | |
|> Enum.map(fn x -> x * x end) | |
|> Enum.reduce(fn x, s -> x + s end) # 55 |
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
[1, 2, 3, 4, 5].map((x) => x * x).reduce((x, s) => x + s); // 55 |
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 = %{ | |
:red => "blue", | |
1 => 2, | |
true => false | |
} | |
map[true] # false | |
map[:red] # "blue" |
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
let map = { | |
red: "blue", | |
1: 2, | |
true: false | |
}; | |
map[true]; // false | |
map["red"]; // "blue" |
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
[1, 2, 3] ++ [4, 5, 6] # [1, 2, 3, 4, 5, 6] | |
[1, 2, 3] -- [2] # [1, 3] |
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
let n = 10; | |
n--; // same as n -= 1; | |
n++; // same as n += 1; |
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
[x, y, z] = [1, 2, 3] | |
{status, message} = {:error, "Unknown error"} | |
[first | everythingElse] = [1, 2, 3, 4, 5] |
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
let [x, y, z] = [1, 2, 3]; | |
let {status, message} = {status: "OK", message: "Unknown error"}; | |
let [first, ...everythingElse] = [1, 2, 3, 4, 5] |
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
twenty_four = 24 | |
not_true = false | |
API_KEY = 'abc123' |
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
var twentyFour = 24; | |
let notTrue = false; | |
const API_KEY = 'abc123'; |