Merge pull request #42 from parkerl/run_elm_format_on_new_exercises

Changes to exercises after an `elm-format`
This commit is contained in:
Erik Simmler 2016-03-19 14:53:41 -04:00
commit 7c74235831
5 changed files with 42 additions and 13 deletions

View file

@ -6,8 +6,11 @@ import String exposing (toLower, toList)
detect : String -> List String -> List String
detect word candidates =
let
original = toLower word
ref = normalize word
original =
toLower word
ref =
normalize word
in
List.filter (\w -> normalize w == ref && toLower w /= original) candidates

View file

@ -4,7 +4,8 @@ module DifferenceOfSquares (..) where
squareOfSum : Int -> Int
squareOfSum n =
let
sum = n * (n + 1) // 2
sum =
n * (n + 1) // 2
in
sum * sum

View file

@ -1,4 +1,4 @@
module Raindrops where
module Raindrops (..) where
import String
@ -7,10 +7,20 @@ raindrops : Int -> String
raindrops number =
let
drops =
[ if number % 3 == 0 then "Pling" else ""
, if number % 5 == 0 then "Plang" else ""
, if number % 7 == 0 then "Plong" else ""
[ if number % 3 == 0 then
"Pling"
else
""
, if number % 5 == 0 then
"Plang"
else
""
, if number % 7 == 0 then
"Plong"
else
""
]
result =
String.join "" drops
in

View file

@ -13,16 +13,29 @@ toRNA dna =
|> Result.map (String.join "")
-- Copied from elm-result-extra
resultExtraCombine : List (Result x a) -> Result x (List a)
resultExtraCombine = List.foldr (Result.map2 (::)) (Ok [])
resultExtraCombine =
List.foldr (Result.map2 (::)) (Ok [])
toRNANucleotide : Char -> Result Char Char
toRNANucleotide nuc =
case nuc of
'C' -> Ok 'G'
'G' -> Ok 'C'
'A' -> Ok 'U'
'T' -> Ok 'A'
_ -> Err nuc
'C' ->
Ok 'G'
'G' ->
Ok 'C'
'A' ->
Ok 'U'
'T' ->
Ok 'A'
_ ->
Err nuc

View file

@ -5,11 +5,13 @@ import List exposing (head, tail)
import Maybe exposing (withDefault)
import Regex
{-
To the unaware: this was written by a very green elmer, so don't consider
it an idiomatic exemplar to emulate.
-}
encode : String -> String
encode string =
String.toList string