Skip to content
Snippets Groups Projects
Commit 8deb6d32 authored by Dahmane Lynda's avatar Dahmane Lynda
Browse files

tris-fusion

parent cf412c1a
No related branches found
No related tags found
No related merge requests found
File added
......@@ -122,7 +122,18 @@ def is_sorted(l: ApLst, comp: Callable[[T, T], int]=compare) -> bool:
$$$ is_sorted(native_to_list([1, 2, 4, 3]))
False
"""
...
if l.is_empty():
return True
else:
if l.tail().is_empty():
return True
else:
if comp(l.head(), l.tail().head())>0:
return False
else:
return is_sorted(l.tail(), comp)
def split(l: ApLst) -> tuple[ApLst, ApLst]:
......@@ -141,8 +152,7 @@ def split(l: ApLst) -> tuple[ApLst, ApLst]:
$$$ all(k in l for k in l3)
True
"""
...
def merge(l1: ApLst, l2: ApLst,
comp: Callable[[T, T], int]=compare) -> ApLst:
......@@ -156,8 +166,7 @@ def merge(l1: ApLst, l2: ApLst,
$$$ list_to_native(merge(native_to_list([1, 3, 4, 9]), native_to_list([1, 2, 5])))
[1, 1, 2, 3, 4, 5, 9]
"""
...
def mergesort(l: ApLst, comp: Callable[[T, T], int]=compare) -> ApLst:
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment