mirror of
https://github.com/correl/elm.git
synced 2025-03-07 04:35:48 -10:00
Accumulate
This commit is contained in:
parent
253e31529b
commit
6072ca7ff8
4 changed files with 34 additions and 2 deletions
7
Accumulate/AccumulateExample.elm
Normal file
7
Accumulate/AccumulateExample.elm
Normal 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 ->
|
22
Accumulate/AccumulateTest.elm
Normal file
22
Accumulate/AccumulateTest.elm
Normal 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
|
|
@ -19,7 +19,8 @@
|
|||
"run-length-encoding"
|
||||
],
|
||||
"deprecated": [
|
||||
|
||||
"Leap",
|
||||
"Accumulate"
|
||||
],
|
||||
"ignored": [
|
||||
"bin",
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
"./exercises/difference-of-squares",
|
||||
"./exercises/anagram",
|
||||
"./exercises/raindrops",
|
||||
"./exercises/triangle"
|
||||
"./exercises/triangle",
|
||||
"Leap",
|
||||
"Accumulate"
|
||||
],
|
||||
"exposed-modules": [],
|
||||
"dependencies": {
|
||||
|
|
Loading…
Add table
Reference in a new issue