diff options
| author | Edoardo La Greca | 2025-09-10 21:29:24 +0200 |
|---|---|---|
| committer | Edoardo La Greca | 2025-09-10 21:29:24 +0200 |
| commit | f5d3c9762c02284a0ae07541d963aa733cad8a25 (patch) | |
| tree | 7b23cd85c78958ac0d38395064b9b77fc76d0d97 /lec07 | |
| parent | 125dcc2372f01da088b603676bf4870e6aafb843 (diff) | |
implement dropJ from second exercise of lecture 7
Diffstat (limited to 'lec07')
| -rw-r--r-- | lec07/JoinList.hs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lec07/JoinList.hs b/lec07/JoinList.hs index 7ec30a9..61df8da 100644 --- a/lec07/JoinList.hs +++ b/lec07/JoinList.hs @@ -28,3 +28,14 @@ indexJ n (Append m jl1 jl2) | n >= tag1 = indexJ (n - tag1) jl2 where tag1 = tag jl1 +dropJ :: (Sized b, Monoid b) => Int -> JoinList b a -> JoinList b a +dropJ _ Empty = Empty +dropJ n jl + | n <= 0 = jl +dropJ n (Single _ _) + | n >= 1 = Empty +dropJ n (Append m jl1 jl2) + | n >= m = Empty + | n >= tag1 = jl2 + where tag1 = tag jl1 + |