From f5d3c9762c02284a0ae07541d963aa733cad8a25 Mon Sep 17 00:00:00 2001 From: Edoardo La Greca Date: Wed, 10 Sep 2025 21:29:24 +0200 Subject: implement dropJ from second exercise of lecture 7 --- lec07/JoinList.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 + -- cgit v1.2.3