mirror of
https://github.com/correl/elm.git
synced 2024-12-22 03:00:07 +00:00
Changes to exercises after an elm-format
This commit is contained in:
parent
8ead7aabfb
commit
5a8aa5e7de
5 changed files with 42 additions and 13 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue