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
# https://projecteuler.net/index.php?section=problems&id=50 | |
defmodule Primes do | |
def primes(ceiling), do: Enum.filter(1..ceiling, fn x -> is_prime(x) end) | |
def is_prime(n), do: factors(n, div(n, 2)) == [1] | |
def factors(1, _), do: [1] | |
def factors(_, 1), do: [1] | |
def factors(n, i) do | |
if rem(n, i) == 0 do |
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
" when triggering this command, vim will grab your path and line location and pass it along | |
map <Leader>el :call RemoteSendCommand(TestLineCommand(expand("%:p"), line(".")))<CR> | |
" because I'm mostly writing Elixir and making heavy use of the REPL while writing my tests, | |
" I made a specific command to user with Mix, the Elixir task utility | |
" But I'm sure you could get this to work with vim-test or something like that | |
function! TestLineCommand(path, line_number) | |
let cmd = join(["mix test --only", " line:", a:line_number, " ", a:path], "") | |
return cmd | |
endfunction |
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
defmodule Rover do | |
@directions ["N", "E", "S", "W"] | |
def execute(location_string, moves_string) do | |
location = parse_location(location_string) | |
moves = parse_moves(moves_string) | |
process_move(location, moves) | |
end |
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
¯\_(ツ)_/¯ iex -S mix | |
Erlang/OTP 22 [erts-10.4.4] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] | |
Interactive Elixir (1.9.1) - press Ctrl+C to exit (type h() ENTER for help) | |
iex(1)> :scheduler.sample() |> :scheduler.utilization() | |
[ | |
{:total, 0.081145584725537, '8.1%'}, | |
{:normal, 1, 0.057692307692307696, '5.8%'}, | |
{:normal, 2, 0.06521739130434782, '6.5%'}, | |
{:normal, 3, 0.34545454545454546, '34.5%'}, |