##### Differences

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

 sesiuni:scala:lab3 [2016/06/29 17:06]dciocirlan [Practice] sesiuni:scala:lab3 [2016/06/29 17:12] (current)dciocirlan [Practice] Both sides previous revision Previous revision 2016/06/29 17:12 dciocirlan [Practice] 2016/06/29 17:06 dciocirlan [Practice] 2016/06/29 17:05 dciocirlan [Practice] 2016/06/29 17:00 dciocirlan [3 - Functional Programming Basics] 2016/06/29 16:59 dciocirlan 2016/06/29 13:22 dciocirlan created 2016/06/29 17:12 dciocirlan [Practice] 2016/06/29 17:06 dciocirlan [Practice] 2016/06/29 17:05 dciocirlan [Practice] 2016/06/29 17:00 dciocirlan [3 - Functional Programming Basics] 2016/06/29 16:59 dciocirlan 2016/06/29 13:22 dciocirlan created 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:\\ List(1,2) -> List(1, "​one",​ 2, "​two"​)​ * given a List of integers, return a new list which contains the integers //and// their String representation;​ example:\\ List(1,2) -> List(1, "​one",​ 2, "​two"​)​ + - 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!