From 047b4b4c62acc625ecae744572bbec1ea0a861ae Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
Date: Wed, 24 Dec 2014 22:31:35 +0530
Subject: [PATCH] hw7: exersize 2, part 2

---
 hw7/JoinList.hs | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/hw7/JoinList.hs b/hw7/JoinList.hs
index 6ef51a8..b7a4aeb 100644
--- a/hw7/JoinList.hs
+++ b/hw7/JoinList.hs
@@ -30,3 +30,14 @@ indexJ _ (Single _ a) = Just a
 indexJ n (Append _ l r) | n < (getSize (size (tag l))) = indexJ n l
                         | otherwise = indexJ (n - getSize (size (tag l))) r
 
+-- 2. drop
+dropJ :: (Sized b, Monoid b) =>
+         Int -> JoinList b a -> JoinList b a
+dropJ 0 x = x
+dropJ _ Empty = Empty
+dropJ _ (Single _ _) = Empty
+dropJ n x | (getSize (size (tag x))) < n = Empty
+dropJ n (Append _ l r) | n > (getSize (size (tag l))) =
+                           dropJ (n - getSize (size (tag l))) r
+                       | otherwise = let lft = dropJ n l in
+                                     Append ((tag lft) `mappend` (tag r)) lft r
-- 
2.45.2