Conversation
|
First, apologies for taking so long. I wasn't actually watching the repo so I didn't get notified about your PRs Second, isn't this exercise generally deprecated in favour of list-ops? Nevertheless, I'll review and merge when ready. |
| pending 'keeps strings', -> | ||
| result = Strain.keep {'apple', 'zebra', 'banana', 'zombies', 'cherimoya', 'zealot'}, (x) -> starts_with x, 'z' | ||
| expected = {'zebra', 'zombies', 'zealot'} | ||
| assert.are.same expected, result |
There was a problem hiding this comment.
I think this would be more readable like:
| pending 'keeps strings', -> | |
| result = Strain.keep {'apple', 'zebra', 'banana', 'zombies', 'cherimoya', 'zealot'}, (x) -> starts_with x, 'z' | |
| expected = {'zebra', 'zombies', 'zealot'} | |
| assert.are.same expected, result | |
| pending 'keeps strings', -> | |
| list = {'apple', 'zebra', 'banana', 'zombies', 'cherimoya', 'zealot'} | |
| predicate = (x) -> starts_with x, 'z' | |
| result = Strain.keep list, predicate | |
| expected = {'zebra', 'zombies', 'zealot'} | |
| assert.are.same expected, result |
and the prediate variable can be more descriptive, like
predicate = (str) -> starts_with str, 'z'
-- or
predicate = (sublist) -> contains sublist, 5
-- or
predicate = (_) -> true -- always trueI'll look at the generator
There was a problem hiding this comment.
Yeah, I definitely agree. A little deviance from the problem specs names is fine if it improves readability.
And I was coming here thinking about what new exercises to add, now that I've given you a turn ;) |
You might be thinking of |
No description provided.