accumulate operation, which, given a collection and an
operation to perform on each element of the collection, returns a new
collection containing the result of applying that operation to each element of
the input collection.
Given the collection of numbers:
And the operation:
x => x * x)
Your code should be able to produce the collection of squares:
Check out the test suite to see the expected function signature.
Keep your hands off that collect/map/fmap/whatchamacallit functionality provided by your standard library! Solve this one yourself using other basic tools instead.
Refer to the Installing Elm page for information about installing elm.
The first time you start an exercise, you'll need to ensure you have the appropriate dependencies installed. Thankfully, Elm makes that easy for you and will install dependencies when you try to run tests or build the code.
Execute the tests with:
Automatically run tests again when you save changes:
$ elm-test --watch
As you work your way through the test suite, be sure to remove the
calls from each test until you get them all passing!
Conversation with James Edward Gray II https://twitter.com/jeg2
It is possible to submit an incomplete solution so you can see how others have completed the exercise.
module Tests exposing (square, tests) import Accumulate exposing (accumulate) import Expect import String import Test exposing (..) square : Int -> Int square x = x * x tests : Test tests = describe "Accumulate" [ test " Accumulate" <| \() -> Expect.equal  (accumulate square ) , skip <| test "square Accumulate" <| \() -> Expect.equal [ 1, 4, 9 ] (accumulate square [ 1, 2, 3 ]) , skip <| test "toUpper Accumulate" <| \() -> Expect.equal [ "HELLO", "WORLD" ] (accumulate String.toUpper [ "hello", "world" ]) , skip <| test "reverse Accumulate" <| \() -> Expect.equal [ "olleh", "dlrow" ] (accumulate String.reverse [ "hello", "world" ]) ]
module Accumulate exposing (accumulate) accumulate : (a -> b) -> List a -> List b accumulate func input = case input of head :: tail -> func head :: accumulate func tail  -> 
A huge amount can be learned from reading other people’s code. This is why we wanted to give exercism users the option of making their solutions public.
Here are some questions to help you reflect on this solution and learn the most from it.