added lesson 7
This commit is contained in:
		
							
								
								
									
										8
									
								
								src/MidTermPrep1/Exercices.sc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/MidTermPrep1/Exercices.sc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| def compress[T](list: List[T]): List[T] = { | ||||
|   list.foldRight(List.empty[T])((elmt: T, res: List[T]) => res match { | ||||
|     case head::_ if head == elmt => res | ||||
|     case _ => elmt::res | ||||
|   }) | ||||
| } | ||||
|  | ||||
| compress(List('a', 'a', 'a', 'a', 'b', 'c', 'c', 'a', 'a', 'd', 'e', 'e', 'e', 'e')) | ||||
		Reference in New Issue
	
	Block a user