Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
fp2023:lab04 [2023/03/21 17:45]
pdmatei
fp2023:lab04 [2023/03/24 14:53] (current)
pdmatei
Line 35: Line 35:
 **4.6.** Implement ''​contains''​ which checks if an element is a member of a list. **4.6.** Implement ''​contains''​ which checks if an element is a member of a list.
 <code scala> <code scala>
-def contains(e: Int, l: IList): ​IList = ???+def contains(e: Int, l: IList): ​Boolean ​= ???
 </​code>​ </​code>​
  
 **4.7.** Implement ''​max''​ which returns the largest integer from a list: **4.7.** Implement ''​max''​ which returns the largest integer from a list:
 <code scala> <code scala>
-def max(l: ​Ilist): IList = ???+def max(l: ​IList): Int = ???
 </​code>​ </​code>​
  
-**4.8.** Implement ''​isSorted''​ which checks if a list is sorted:+**4.8.** Implement ''​take''​ which returns ​new list containing the first ''​n''​ elements of the original ​list:
 <code scala> <code scala>
-def isSorted(l: IList): IList = ???+def take(n: Int)(l: IList): IList = ???
 </​code>​ </​code>​
  
-**4.9.** Implement ''​merge''​ which merges two sorted lists:+**4.9.** Implement ''​drop''​ which returns a new list containing the original list without the first ''​n''​ elements: 
 +<code scala> 
 +def drop(n: Int)(l: IList): IList = ??? 
 +</​code>​ 
 + 
 +**4.10.** Implement ''​isSorted''​ which checks if a list is sorted: 
 +<code scala> 
 +def isSorted(l: IList): Boolean = ??? 
 +</​code>​ 
 + 
 +**4.11.** Implement ''​merge''​ which merges two sorted lists:
 <code scala> <code scala>
 def merge(l1: IList, l2: IList): IList = ??? def merge(l1: IList, l2: IList): IList = ???
 </​code>​ </​code>​
  
-**4.10.** Implement ''​mergeSort''​ which sorts a list:+**4.12.** Implement ''​mergeSort''​ which sorts a list:
 <code scala> <code scala>
 def mergesort(l:​ IList) IList = ??? def mergesort(l:​ IList) IList = ???
 </​code>​ </​code>​