Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
fp2023:lab04 [2023/03/22 16:16] bogdan.butnariu |
fp2023:lab04 [2023/03/24 14:53] (current) pdmatei |
||
|---|---|---|---|
| Line 40: | Line 40: | ||
| **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): Int = ??? | + | def max(l: IList): Int = ??? |
| </code> | </code> | ||
| - | **4.8.** Implement ''isSorted'' which checks if a list is sorted: | + | **4.8.** Implement ''take'' which returns a new list containing the first ''n'' elements of the original list: |
| + | <code scala> | ||
| + | def take(n: Int)(l: IList): IList = ??? | ||
| + | </code> | ||
| + | |||
| + | **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> | <code scala> | ||
| def isSorted(l: IList): Boolean = ??? | def isSorted(l: IList): Boolean = ??? | ||
| </code> | </code> | ||
| - | **4.9.** Implement ''merge'' which merges two sorted lists: | + | **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> | ||