Skip to content

parallel-letter-frequency, tournament, word-count: Use Entry#or_insert#155

Merged
petertseng merged 4 commits intoexercism:masterfrom
petertseng:or-insert
Jul 3, 2016
Merged

parallel-letter-frequency, tournament, word-count: Use Entry#or_insert#155
petertseng merged 4 commits intoexercism:masterfrom
petertseng:or-insert

Conversation

@petertseng
Copy link
Copy Markdown
Member

@petertseng petertseng commented Jul 3, 2016

These shorten the functions by removing the need to match on the Entry cases.

This seems good to make the examples more idiomatic.

Note the exercises that still match on Entry cases but were not changed by this PR:

  • grade-school: I judged that pushing an element onto the vector then sorting it was sufficiently different from creating a vector with a single element. I can be convinced otherwise.
  • nucleotide-count: As we discuss in test cases for nucleotide count should include handing of invalid sequences #149, invalid nucleotides should maybe produce errors, so the decision resulting from that discussion may mean using or_insert doesn't make sense.

This drastically shortens the function, avoiding the need to `match` on
the `Entry` cases.
This seems good to make the example more idiomatic.
This drastically shortens the `count` function and result collection
loop in `frequency`, avoiding the need to `match` on the `Entry` cases.
This seems good to make the example more idiomatic.
This drastically shortens the function, avoiding the need to `match` on
the `Entry` cases.
This seems good to make the example more idiomatic.
@petertseng
Copy link
Copy Markdown
Member Author

travis didn't pick this up for testing. kicking it.

@petertseng petertseng closed this Jul 3, 2016
@petertseng petertseng reopened this Jul 3, 2016
This drastically shortens the function, avoiding the need to `match` on
the `Entry` cases.
This seems good to make the example more idiomatic.
@petertseng
Copy link
Copy Markdown
Member Author

I also decided to make the change for grade-school.

@IanWhitney
Copy link
Copy Markdown
Contributor

These are definitely more like the solutions I see being submitted.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants