update rna & word_count with proper formatting (via ElixirLS)

This commit is contained in:
Xevion
2021-01-18 15:50:59 -06:00
parent 3194f81ece
commit e631ea80bc
2 changed files with 5 additions and 3 deletions

View File

@@ -1,6 +1,8 @@
defmodule RnaTranscription do
# Turns all 1-item charlist keys and values inside the base map into integers
@transcription %{'G' => 'C', 'C' => 'G', 'T' => 'A', 'A' => 'U'} |> Enum.map(fn ({k, v}) -> {List.first(k), List.first(v)} end) |> Enum.into(%{})
@transcription %{'G' => 'C', 'C' => 'G', 'T' => 'A', 'A' => 'U'}
|> Enum.map(fn {k, v} -> {List.first(k), List.first(v)} end)
|> Enum.into(%{})
@doc """
Transcribes a character list representing DNA nucleotides to RNA
@@ -12,6 +14,6 @@ defmodule RnaTranscription do
"""
@spec to_rna([char]) :: [char]
def to_rna(dna) do
dna |> Enum.map(fn (x) -> Map.get(@transcription, x) end)
dna |> Enum.map(fn x -> Map.get(@transcription, x) end)
end
end

View File

@@ -12,6 +12,6 @@ defmodule WordCount do
|> String.downcase()
|> String.split(@splitters)
|> Enum.filter(&(String.length(&1) > 0))
|> Enum.reduce(%{}, fn (word, count) -> Map.update(count, word, 1, &(&1 + 1)) end)
|> Enum.reduce(%{}, fn word, count -> Map.update(count, word, 1, &(&1 + 1)) end)
end
end