devNoo

musings of a Software Developer

Seven languages in seven weeks: My solutions for scala day 2

| 0 comments

Finally I have time and energy to continue my voyage trough the book Seven languages in seven weeks. The chapter focuses on collections and the functional programming that you can do on them.
Well because it is some time I go I read the chapter and did the exercises I will just include the solution without further ado.

Use fold left to compute the total size of a list of strings

For a good introduction to fold left and fold right look at this thread on stackoverflow.

Censoring text
The second exercise consists of writing a censor trait than will offer functionality to censor the words Shoot and Darn in a given text.

Censor dictionary
The next exercise is the same as above, but now the text had to come from a file.

.

Ok this was all for scala day2, please leave comments on the code.

Leave a Reply

Required fields are marked *.

*