Sha256: 52bea875b8722618b06b83460ac0990a0caa01c9eba1ba9c85293f2c99d913c4

Contents?: true

Size: 1.51 KB

Versions: 174

Compression:

Stored size: 1.51 KB

Contents

# Strain

Implement the `keep` and `discard` operation on collections. Given a collection
and a predicate on the collection's elements, `keep` returns a new collection
containing those elements where the predicate is true, while `discard` returns
a new collection containing those elements where the predicate is false.

For example, given the collection of numbers:

- 1, 2, 3, 4, 5

And the predicate:

- is the number even?

Then your keep operation should produce:

- 2, 4

While your discard operation should produce:

- 1, 3, 5

Note that the union of keep and discard is all the elements.

The functions may be called `keep` and `discard`, or they may need different
names in order to not clash with existing functions or concepts in your
language.

## Restrictions

Keep your hands off that filter/reject/whatchamacallit functionality
provided by your standard library!  Solve this one yourself using other
basic tools instead.

* * * *

For installation and learning resources, refer to the [exercism help page][].

[exercism help page]: http://exercism.io/languages/lfe

To run the provided tests, you will need `make`.
Open a terminal window and run the following from the exercise directory:

```sh
make test
```

You should now be able to see the results of the test suite for the exercise.

## Source

Conversation with James Edward Gray II [https://twitter.com/jeg2](https://twitter.com/jeg2)

## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

Version data entries

174 entries across 174 versions & 1 rubygems

Version Path
trackler-2.2.1.159 tracks/lfe/exercises/strain/README.md
trackler-2.2.1.158 tracks/lfe/exercises/strain/README.md
trackler-2.2.1.157 tracks/lfe/exercises/strain/README.md
trackler-2.2.1.156 tracks/lfe/exercises/strain/README.md
trackler-2.2.1.155 tracks/lfe/exercises/strain/README.md
trackler-2.2.1.154 tracks/lfe/exercises/strain/README.md
trackler-2.2.1.153 tracks/lfe/exercises/strain/README.md
trackler-2.2.1.152 tracks/lfe/exercises/strain/README.md
trackler-2.2.1.151 tracks/lfe/exercises/strain/README.md
trackler-2.2.1.150 tracks/lfe/exercises/strain/README.md
trackler-2.2.1.149 tracks/lfe/exercises/strain/README.md
trackler-2.2.1.148 tracks/lfe/exercises/strain/README.md
trackler-2.2.1.147 tracks/lfe/exercises/strain/README.md
trackler-2.2.1.146 tracks/lfe/exercises/strain/README.md
trackler-2.2.1.145 tracks/lfe/exercises/strain/README.md
trackler-2.2.1.144 tracks/lfe/exercises/strain/README.md
trackler-2.2.1.143 tracks/lfe/exercises/strain/README.md
trackler-2.2.1.142 tracks/lfe/exercises/strain/README.md
trackler-2.2.1.141 tracks/lfe/exercises/strain/README.md
trackler-2.2.1.140 tracks/lfe/exercises/strain/README.md