Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
26
Task/Odd-word-problem/Elixir/odd-word-problem.elixir
Normal file
26
Task/Odd-word-problem/Elixir/odd-word-problem.elixir
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
defmodule Odd_word do
|
||||
def handle(s, false, i, o) when ((s >= "a" and s <= "z") or (s >= "A" and s <= "Z")) do
|
||||
o.(s)
|
||||
handle(i.(), false, i, o)
|
||||
end
|
||||
def handle(s, t, i, o) when ((s >= "a" and s <= "z") or (s >= "A" and s <= "Z")) do
|
||||
d = handle(i.(), :rec, i, o)
|
||||
o.(s)
|
||||
if t == true, do: handle(d, t, i, o), else: d
|
||||
end
|
||||
def handle(s, :rec, _, _), do: s
|
||||
def handle(?., _, _, o), do: o.(?.); :done
|
||||
def handle(:eof, _, _, _), do: :done
|
||||
def handle(s, t, i, o) do
|
||||
o.(s)
|
||||
handle(i.(), not t, i, o)
|
||||
end
|
||||
|
||||
def main do
|
||||
i = fn() -> IO.getn("") end
|
||||
o = fn(s) -> IO.write(s) end
|
||||
handle(i.(), false, i, o)
|
||||
end
|
||||
end
|
||||
|
||||
Odd_word.main
|
||||
Loading…
Add table
Add a link
Reference in a new issue