5rep : (n : Nat) -> Char -> Vect n Char
7rep (S k) x = x :: rep k x
9data RLE : Vect n Char -> Type where
16 -> RLE (rep (S n) x ++ xs)
18eq : (x : Char) -> (y : Char) -> Maybe (x = y)
19eq x y = if x == y then Just (believe_me (Refl {x})) else Nothing
23rle : (xs : Vect n Char) -> RLE xs
25rle (x :: xs) with (rle xs)
26 rle (x :: Vect.Nil) | REnd = RChar Z x REnd
27 rle (x :: rep (S n) yvar ++ ys) | RChar n yvar rs with (eq x yvar)
28 rle (x :: rep (S n) x ++ ys) | RChar n x rs | Just Refl
30 rle (x :: rep (S n) y ++ ys) | RChar n y rs | Nothing
31 = RChar Z x (RChar n y rs)
33compress : Vect n Char -> String
34compress xs with (rle xs)
35 compress Nil | REnd = ""
36 compress (rep (S n) x ++ xs) | RChar _ _ rs
37 = let ni : Integer = cast (S n) in
38 show ni ++ strCons x (compress xs)
41fmt : {xs : Vect n Char} -> RLE xs -> String
43fmt (RChar n c xs) = show n ++ show c ++ fmt xs
46compressString : String -> String
47compressString xs = compress (fromList (unpack xs))
50main = putStrLn (compressString "foooobaaaarbaaaz")
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list