]> git.rkrishnan.org Git - yorgey.git/blobdiff - hw7/JoinList.hs
dropJ: handle the negative n case
[yorgey.git] / hw7 / JoinList.hs
index b7a4aeb949599db702dfd0696d9e4cd2a4261581..7f13837e02d6bb79962d1fc654a6df9da70b5f4f 100644 (file)
@@ -33,6 +33,7 @@ indexJ n (Append _ l r) | n < (getSize (size (tag l))) = indexJ n l
 -- 2. drop
 dropJ :: (Sized b, Monoid b) =>
          Int -> JoinList b a -> JoinList b a
+dropJ n x | n < 0 = x
 dropJ 0 x = x
 dropJ _ Empty = Empty
 dropJ _ (Single _ _) = Empty