mirror of
https://github.com/Xevion/exercism.git
synced 2025-12-07 09:15:02 -06:00
update rna & word_count with proper formatting (via ElixirLS)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user