Skip to content

Instantly share code, notes, and snippets.

@ga-wolf
Created September 14, 2015 23:01
Show Gist options
  • Save ga-wolf/1415ca77ae91f0da279d to your computer and use it in GitHub Desktop.
Save ga-wolf/1415ca77ae91f0da279d to your computer and use it in GitHub Desktop.
Accumulate Warmup

Accumulate

For example, given the collection of numbers:

  • 1, 2, 3, 4, 5

And the operation:

  • square a number

Your code should be able to produce the collection of squares:

  • 1, 4, 9, 16, 25

Optional Extras

  • Square Root a Number

  • Cube a number

  • Even and Odd

  • Or return an object containing all of those things:

    {
      original: [1, 2, 3, 4, 5],
      squares: [...],
      squareRoots: [...],
      cubes: [...],
      evenAndOdd: [true, false, true]
    }
    

Restrictions

Keep your hands off that collect/map/fmap/whatchamacallit functionality provided by your standard library!

Solve this one yourself using other basic tools instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment