Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
sesiuni:scala:lab3 [2016/06/29 17:06]
dciocirlan [Practice]
sesiuni:scala:lab3 [2016/06/29 17:12] (current)
dciocirlan [Practice]
Line 23: Line 23:
     * given a List of integers, return a new list with the number of digits of each element     * given a List of integers, return a new list with the number of digits of each element
     * given a List of integers, return a new list which contains the integers //and// their String representation;​ example:\\ <code scala> List(1,2) -> List(1, "​one",​ 2, "​two"​)</​code>​     * given a List of integers, return a new list which contains the integers //and// their String representation;​ example:\\ <code scala> List(1,2) -> List(1, "​one",​ 2, "​two"​)</​code>​
 +  - implement a Cons-based List of integers
 +    * create two case classes: **Nil** for an empty list, and **Cons** which has a //head// (integer) and a //tail// (the rest of the list)
 +      * there are some important questions you should ask first before you start coding...
 +    * implement //map, flatMap and filter//
 +      * watch for the signatures first
 +      * implement recursively (bonus for who does tail recursion ;) )
 +      * you might want to implement some auxiliary functions
 +    * create an instance of a Cons-based List you've just implemented
 +    * extract only the prime numbers from your list, then count the number of digits for each
 +      * use a for-comprehension!
sesiuni/scala/lab3.txt · Last modified: 2016/06/29 17:12 by dciocirlan