Update elm files to 0.18

This commit is contained in:
Erik Simmler 2016-12-17 17:15:34 -05:00
parent 26eabeb239
commit da75a819f8
11 changed files with 27 additions and 27 deletions

View file

@ -12,9 +12,9 @@ isAllergicTo name score =
toList : Int -> List String
toList score =
allergies
|> List.indexedMap (\i n -> ( Bitwise.shiftLeft 1 i, n ))
|> List.indexedMap (\i n -> ( Bitwise.shiftLeftBy i 1, n ))
|> List.filter (\( s, n ) -> Bitwise.and s score > 0)
|> List.map snd
|> List.map Tuple.second
allergies : List String

View file

@ -137,7 +137,7 @@ listOfCharacters length characterList =
gibberish : Int -> Random.Generator Char -> String
gibberish length characterList =
fst (Random.step (Random.map String.fromList (listOfCharacters length characterList)) (Random.initialSeed 424242))
Tuple.first (Random.step (Random.map String.fromList (listOfCharacters length characterList)) (Random.initialSeed 424242))
uppercaseGibberish : Int -> String

View file

@ -12,7 +12,7 @@ squareOfSum n =
sumOfSquares : Int -> Int
sumOfSquares n =
List.sum (List.map (\m -> m * m) [0..n])
List.sum (List.map (\m -> m * m) (List.range 0 n))
difference : Int -> Int

View file

@ -37,4 +37,4 @@ studentsInGrade grade school =
allStudents : School -> List ( Grade, List Student )
allStudents school =
Dict.toList school |> List.sortBy fst
Dict.toList school |> List.sortBy Tuple.first

View file

@ -14,57 +14,57 @@ tests =
[ test "empty list" <|
\() -> Expect.equal 0 (ListOps.length [])
, test "non-empty list" <|
\() -> Expect.equal 4 (ListOps.length [1..4])
\() -> Expect.equal 4 (ListOps.length (List.range 1 4))
]
, describe "reverse"
[ test "empty list" <|
\() -> Expect.equal [] (ListOps.reverse [])
, test "non-empty list" <|
\() -> Expect.equal [ 4, 3, 2, 1 ] (ListOps.reverse [1..4])
\() -> Expect.equal [ 4, 3, 2, 1 ] (ListOps.reverse (List.range 1 4))
]
, describe "map"
[ test "empty list" <|
\() -> Expect.equal [] (ListOps.map ((+) 1) [])
, test "non-empty list" <|
\() -> Expect.equal [2..5] (ListOps.map ((+) 1) [1..4])
\() -> Expect.equal (List.range 2 5) (ListOps.map ((+) 1) (List.range 1 4))
]
, describe "filter"
[ test "empty list" <|
\() -> Expect.equal [] (ListOps.filter (\_ -> True) [])
, test "non-empty list" <|
\() -> Expect.equal [ 2, 4 ] (ListOps.filter (\x -> x % 2 == 0) [1..4])
\() -> Expect.equal [ 2, 4 ] (ListOps.filter (\x -> x % 2 == 0) (List.range 1 4))
]
, describe "foldl"
[ test "empty list" <|
\() -> Expect.equal 0 (ListOps.foldl (+) 0 [])
, test "non-empty list" <|
\() -> Expect.equal 10 (ListOps.foldl (+) 0 [1..4])
\() -> Expect.equal 10 (ListOps.foldl (+) 0 (List.range 1 4))
, test "direction" <|
\() -> Expect.equal [ 4, 3, 2, 1 ] (ListOps.foldl (::) [] [1..4])
\() -> Expect.equal [ 4, 3, 2, 1 ] (ListOps.foldl (::) [] (List.range 1 4))
]
, describe "foldr"
[ test "empty list" <|
\() -> Expect.equal 0 (ListOps.foldr (+) 0 [])
, test "non-empty list" <|
\() -> Expect.equal 10 (ListOps.foldr (+) 0 [1..4])
\() -> Expect.equal 10 (ListOps.foldr (+) 0 (List.range 1 4))
, test "direction" <|
\() -> Expect.equal [1..4] (ListOps.foldr (::) [] [1..4])
\() -> Expect.equal (List.range 1 4) (ListOps.foldr (::) [] (List.range 1 4))
]
, describe "append"
[ test "empty lists" <|
\() -> Expect.equal [] (ListOps.append [] [])
, test "empty and non-empty lists" <|
\() -> Expect.equal [1..4] (ListOps.append [] [1..4])
\() -> Expect.equal (List.range 1 4) (ListOps.append [] (List.range 1 4))
, test "non-empty and empty lists" <|
\() -> Expect.equal [1..4] (ListOps.append [1..4] [])
\() -> Expect.equal (List.range 1 4) (ListOps.append (List.range 1 4) [])
, test "non-empty lists" <|
\() -> Expect.equal [1..8] (ListOps.append [1..4] [5..8])
\() -> Expect.equal (List.range 1 8) (ListOps.append (List.range 1 4) (List.range 5 8))
]
, describe "concat"
[ test "empty list" <|
\() -> Expect.equal [] (ListOps.concat [])
, test "list of lists" <|
\() -> Expect.equal [1..10] (ListOps.concat [ [1..3], [], [4..7], [8..10] ])
\() -> Expect.equal (List.range 1 10) (ListOps.concat [ List.range 1 3, [], List.range 4 7, List.range 8 10 ])
]
]

View file

@ -33,7 +33,7 @@ tests =
]
)
, describe "turn right"
([1..3]
((List.range 1 3)
|> List.scanl (\_ r -> turnRight r) defaultRobot
|> List.map .bearing
|> assertionList [ North, East, South, West ]
@ -41,7 +41,7 @@ tests =
)
, describe
"turn left"
([1..3]
((List.range 1 3)
|> List.scanl (\_ r -> turnLeft r) defaultRobot
|> List.map .bearing
|> assertionList [ North, West, South, East ]

View file

@ -37,7 +37,7 @@ countChars current counted =
[ ( 1, current ) ]
stringifyCounts : ( number, Char ) -> String
stringifyCounts : ( comparable, Char ) -> String
stringifyCounts ( count, char ) =
if count > 1 then
toString count ++ fromChar char
@ -51,7 +51,7 @@ decode string =
|> Regex.find Regex.All (Regex.regex "(\\d+)|(\\D)")
|> List.map .match
|> List.foldl expandCounts ( "", Nothing )
|> fst
|> Tuple.first
expandCounts : String -> ( String, Maybe Int ) -> ( String, Maybe Int )

View file

@ -23,7 +23,7 @@ isFirstLetter letter word =
(String.left 1 word) == letter
lessThanTen : number -> Bool
lessThanTen : comparable -> Bool
lessThanTen num =
num < 10

View file

@ -31,9 +31,9 @@ tests =
, test "partially matching sublist at start" <|
\() -> Expect.equal Sublist (sublist [ 1, 1, 2 ] [ 1, 1, 1, 2 ])
, test "sublist early in huge list" <|
\() -> Expect.equal Sublist (sublist [ 3, 4, 5 ] [1..100000])
\() -> Expect.equal Sublist (sublist [ 3, 4, 5 ] (List.range 1 100000))
, test "huge sublist not in list" <|
\() -> Expect.equal Unequal (sublist [10..5001] [1..5000])
\() -> Expect.equal Unequal (sublist (List.range 10 5001) (List.range 1 5000))
, test "superlist at start" <|
\() -> Expect.equal Superlist (sublist [ 1, 2, 3, 4, 5 ] [ 1, 2, 3 ])
, test "superlist in middle" <|
@ -43,7 +43,7 @@ tests =
, test "partially matching superlist at start" <|
\() -> Expect.equal Superlist (sublist [ 1, 1, 1, 2 ] [ 1, 1, 2 ])
, test "superlist early in huge list" <|
\() -> Expect.equal Superlist (sublist [1..100000] [ 3, 4, 5 ])
\() -> Expect.equal Superlist (sublist (List.range 1 100000) [ 3, 4, 5 ])
, test "recurring values sublist" <|
\() -> Expect.equal Sublist (sublist [ 1, 2, 1, 2, 3 ] [ 1, 2, 3, 1, 2, 1, 2, 3, 2, 1 ])
, test "recurring values unequal" <|

View file

@ -3,7 +3,7 @@ module SumOfMultiples exposing (..)
sumOfMultiples : List Int -> Int -> Int
sumOfMultiples multiples limit =
List.sum (List.filter (inMultiples multiples) [1..(limit - 1)])
List.sum (List.filter (inMultiples multiples) (List.range 1 (limit - 1)))
inMultiples : List Int -> Int -> Bool

View file

@ -14,7 +14,7 @@ version =
2
triangleKind : number -> number -> number -> Result String Triangle
triangleKind : comparable -> comparable -> comparable -> Result String Triangle
triangleKind x y z =
if x <= 0 || y <= 0 || z <= 0 then
Err "Invalid lengths"