| otherwise = let lft = dropJ n l in
Append ((tag lft) `mappend` (tag r)) lft r
+-- 3. take
+takeJ :: (Sized b, Monoid b) =>
+ Int -> JoinList b a -> JoinList b a
+takeJ 0 _ = Empty
+takeJ n _ | n < 0 = Empty
+takeJ _ Empty = Empty
+takeJ n v@(Single _ _) | n == 0 = v
+ | otherwise = Empty
+takeJ n v@(Append t l r) | n > getSize (size t) = v
+ | n < getSize (size (tag l)) = takeJ n l
+ | otherwise = let rt = takeJ (n - getSize (size (tag l))) r in
+ Append ((tag l) `mappend` (tag rt)) l rt
+