Skip to content

Instantly share code, notes, and snippets.

@uxjp
Created September 25, 2022 03:40
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save uxjp/854b1e591aadf2be2eaea05d4b5e65c7 to your computer and use it in GitHub Desktop.
fp-list-length without libs
defmodule Arr do
def count(arr) do
c(arr, 0)
end
def c([_ | tail], acc) do
c(tail, acc + 1)
end
def c([], acc) do
acc
end
end
defmodule Solution do
IO.read(:all)
|> String.split
|> Enum.map(&String.to_integer/1)
|> Arr.count
|> IO.puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment