Accumulate

This commit is contained in:
Benjamin Watts 2015-09-12 13:38:29 -07:00 committed by Erik Simmler
parent 253e31529b
commit 6072ca7ff8
4 changed files with 34 additions and 2 deletions

View file

@ -0,0 +1,7 @@
module AccumulateExample where
accumulate : (a -> b) -> List a -> List b
accumulate func input = List.map func input
-- case input of
-- [] -> []
-- otherwise ->

View file

@ -0,0 +1,22 @@
module AccumulateTest where
-- TODO - remove example inclusion once Problem sets are ready to go live or CI is set up.
import AccumulateExample exposing (accumulate)
import ElmTest.Test exposing (test, Test, suite)
import ElmTest.Assertion exposing (assert, assertEqual)
import ElmTest.Runner.Element exposing (runDisplay)
import String
square : Int -> Int
square x = x * x
tests : Test
tests = suite "Accumulate"
[ test "[]] Accumulate" (assertEqual [] (accumulate square [])),
test "square Accumulate" (assertEqual [1,4,9] (accumulate square [1,2,3])),
test "toUpper Accumulate" (assertEqual ["HELLO","WORLD"] (accumulate String.toUpper ["hello" , "world"])),
test "reverse Accumulate" (assertEqual ["olleh","dlrow"] (accumulate String.reverse ["hello" , "world"]))
]
main = runDisplay tests

View file

@ -19,7 +19,8 @@
"run-length-encoding"
],
"deprecated": [
"Leap",
"Accumulate"
],
"ignored": [
"bin",

View file

@ -16,7 +16,9 @@
"./exercises/difference-of-squares",
"./exercises/anagram",
"./exercises/raindrops",
"./exercises/triangle"
"./exercises/triangle",
"Leap",
"Accumulate"
],
"exposed-modules": [],
"dependencies": {