Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
fp:homework02-draft [2022/03/31 13:35] pdmatei |
fp:homework02-draft [2022/03/31 13:38] (current) pdmatei |
||
---|---|---|---|
Line 58: | Line 58: | ||
**2.** Write a function which computes a list of ''Token'' from a list of strings. Recall that Tokens keep track of the string frequency. Use an auxiliary function | **2.** Write a function which computes a list of ''Token'' from a list of strings. Recall that Tokens keep track of the string frequency. Use an auxiliary function | ||
- | ''insWord'' which inserts a new string in a list of Tokens. If the string is already a token, its frequency is incremented, otherwise it is added as a new token. | + | ''insWord'' which inserts a new string in a list of Tokens. If the string is already a token, its frequency is incremented, otherwise it is added as a new token. (//Hint: the cleanest way to implement aux is to use one of the two folds//). |
<code scala> | <code scala> | ||
def computeTokens(words: List[String]): List[Token] = { | def computeTokens(words: List[String]): List[Token] = { | ||
Line 104: | Line 104: | ||
def wordCount : Int = ??? | def wordCount : Int = ??? | ||
</code> | </code> | ||
+ | |||
+ | **Note:** In order to be graded, exercises 5 to 9 must rely on a correct implementation of the previous parts of the homework. | ||
===== Using andThen ===== | ===== Using andThen ===== |