In this challenge you'll produce a Set. We're defining the Set
as "a function that accepts a number and returns a boolean." Or, in a fancier looking notation:
type Set = Function(Integer) => Boolean
Or, as Elm would define it:
set : Int -> Bool
This challenge is written in Elm, which you will need to install on your local machine. Follow the Elm install guide for help with this.
You will also need to install the elm-test npm package.
Note: If you install version 0.19.x of Elm, you will also need to install version 0.19.x of elm-test.
Your Sets will only contain integers.
As you produce functions, consider if they can be combined to implement others. In other words, can you implement some function in terms of another? Look for and take advantage of these opportunities when appropriate.
You'll need to write tests for each method you implement. You can run your tests with elm-test
.
Define and test the following methods stubbed out in sets.js
:
- singletonSet
- union
- intersect
- diff
- filter
You have the basic set operations, now we want operations that can operate on the elements in the sets.
- forall
- exists
- map
- toString
You'll notice these methods only operate on bounded integers. Why is this necessary? Describe your thoughts in note.md
.