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
| # To-Do app | |
| run = fn run_fn, state -> | |
| case IO.gets("Choose one of the following options:\n1. List TO-DOs\n2. Add a new TO-DO\n3. Mark TO-DO as completed\n4. Delete TO-DO.\n5. Exit\n>> ") |> String.trim() do | |
| "1" -> | |
| state.to_dos | |
| |> Enum.reverse() | |
| |> Enum.with_index() | |
| |> Enum.map_join("\n", fn {%{todo: todo, completed: completed}, idx} -> | |
| "#{idx}. #{todo} [#{if(completed, do: "✔", else: " ")}]" |
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
| # To-Do app | |
| Mix.install [:exla, {:nx, github: "elixir-nx/nx", sparse: "nx", override: true}] | |
| max_todo_length = 5 | |
| max_todos = 10 | |
| run = fn run_fn, state -> | |
| case IO.gets("Choose one of the following options:\n1. List TO-DOs\n2. Add a new TO-DO\n3. Mark TO-DO as completed\n4. Delete TO-DO.\n5. Exit\n>> ") |> String.trim() do | |
| "1" -> | |
| todos = if state.count > 0, do: Nx.to_list(state.to_dos[0..(state.count - 1)]), else: [] |
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
| #include <cmath> | |
| #include <iostream> | |
| #include <vector> | |
| const uint64_t MAX_UINT64 = std::numeric_limits<uint64_t>::max(); | |
| uint64_t numDigits(std::vector<uint64_t> num) { | |
| // num is described by num[0] + num[1] * MAX_UINT64 + num[2] * MAX_UINT64^2 + ... | |
| if (num.empty()) return 0; |
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
| In [1]: import torch | |
| In [2]: a = torch.arange(3, 4, 5) | |
| In [3]: a = torch.arange(60).reshape(3, 4, 5) | |
| In [4]: b = torch.arange(24).reshape(1, 4, 3, 2) | |
| # Aqui, (junto com o output da linha Out[7]) a gente vê que | |
| # que o tensordot usando contraction axes específicas tem | |
| # esse resultado. |
OlderNewer