Skip to content

Instantly share code, notes, and snippets.

@lyo5ha
Last active March 7, 2019 10:50
Show Gist options
  • Save lyo5ha/909f1389e1c2622b2d08386650f1da0c to your computer and use it in GitHub Desktop.
Save lyo5ha/909f1389e1c2622b2d08386650f1da0c to your computer and use it in GitHub Desktop.
Simple question
defmodule ListCount do
{:ok, string} = Path.expand('~/tutorials/hackerrank/input00.txt') |> Path.absname |> File.read
string
|> String.split("\n")
|> Enum.map(&(String.to_integer(&1)))
|> work
def work([mult|rest]) do
Enum.reduce(rest, [], another_func(num, accum, mult))
end
def another_func(num, accum, mult) do
IO.inspect(num, accum, mult)
end
end
# stacktrace:
== Compilation error in file /Users/lyosha/tutorials/hackerrank/list_count.ex ==
** (CompileError) /Users/lyosha/tutorials/hackerrank/list_count.ex:7: undefined function work/1
(elixir) expanding macro: Kernel.|>/2
/Users/lyosha/tutorials/hackerrank/list_count.ex:7: ListCount (module)
(elixir) lib/kernel/parallel_compiler.ex:201: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6
** (CompileError) compile error
(iex) lib/iex/helpers.ex:192: IEx.Helpers.c/2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment