Ex W10 |home |print view |recent changes |changed September 14, 2018 | exact |You are 54.92.160.119 <- set your identity!

Catchup^

• You might have skipped some exercises due to the testat. This week you have time to catch up

`wlist` AGAIN!^

You have already implemented the `wlist` programm twice (once with `std::string` (Ex4) and once with your `word` (Ex5)). The implementation using `word` should be rather short, only a few lines. Until now your `wlist` output contained the words in ascending order, from `a` to `z`. Modify the existing behavior in the following ways and create two new versions of `wlist`:

• Use a standard functor to change the sorting to descending order `z` to `a`
• Implement a functor that sorts the words by their length. If two words have the same length use the normal order of `word` (ascending order). You might need to provide means for getting the size of a `word`.

Algorithm / Functor Exercises^

wseventh - count words and print out 7th most frequent^

Similar to the wfavorite program from last week, only print the 7th most frequent word.

Do not reuse exact code of `wfavorite`, but again use the most optimal data structure and algorithms for this problem.

woccurrence - cross reference with line numbers^

Read a text from standard input line by line. While reading count the line numbers. Create a data structure that keeps each word (use your word class) together with all line numbers it occurs upon. Print out a sorted list of words (one word per line), each followed by a list of the line numbers it occurs upon.

Example input:

```Hello
Hello again
Song by who?
```
output:
```again 2
by 3
Hello 1 2
Song 3
who 3
```

Filling a vector with squares with standard functors^

Use standard functors and the `std::transform` algorithm to fill an `std::vector` consisting of 10 ones with the 10 squares 1, 4, ..100. Do not use a loop. Do not use `std::iota()`. Do not use a lambda. Start with the following vector:

```    std::vector<unsigned> v(10,1);
```

 |home |print view |recent changes |changed September 14, 2018 | exact |You are 54.92.160.119 <- set your identity! Ex W10