on master help sign in
better show implementation (Z case instead if else for limitation)
commitd953c01d91210509aac3a560a8edf84bd8673090 authorHeather <heather@live.ru> dateTue 28 Apr 2015, 16:31 (11 years ago) parent83a0a20
1 file changed+2−4
libs/contrib/Data/CoList.idr+2−4
libs/contrib/Data/CoList.idr+2−4
@@ -26,12 +26,10 @@ instance Functor CoList where
2626instance Show a => Show (CoList a) where
2727 show xs = "[" ++ show' "" 20 xs ++ "]" where
2828 show' : String -> (n : Nat) -> (xs : CoList a) -> String
29− show' acc Z _ = acc
29+ show' acc Z _ = acc ++ "..."
3030 show' acc (S n) [] = acc
3131 show' acc (S n) [x] = acc ++ show x
32− show' acc (S n) (x :: xs) =
33− if n > 0 then show' (acc ++ (show x) ++ ", ") n xs
34− else acc ++ (show x) ++ ", ..."
32+ show' acc (S n) (x :: xs) = show' (acc ++ (show x) ++ ", ") n xs
3533
3634||| Take the first `n` elements of `xs`
3735|||