Skip to content

Instantly share code, notes, and snippets.

@frerich
Created June 21, 2023 14:25
Show Gist options
  • Save frerich/6ab04d6c2337f46122c1f3ec7ec8b863 to your computer and use it in GitHub Desktop.
Save frerich/6ab04d6c2337f46122c1f3ec7ec8b863 to your computer and use it in GitHub Desktop.
IO.stream(:line)
|> Stream.map(&String.trim_trailing/1)
|> Enum.reduce(%{}, fn
"list", todo -> IO.inspect(todo)
"add " <> item, todo -> Map.put(todo, item, false)
"complete " <> item, todo -> Map.put(todo, item, true)
"delete " <> item, todo -> Map.delete(todo, item)
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment